title: How to shorten URL using PHP Bitly v4?
body: <p>I have this code for Bitly <strong>v3</strong> and it is working well.</p>
  
  <pre><code>&lt;?php
  $login = 'login-code-here';
  $api_key = 'api-key-here';
  $long_url = 'https://stackoverflow.com/questions/ask';
  
  $ch = curl_init('http://api.bitly.com/v3/shorten?login='.$login.'&amp;apiKey='.$api_key.'&amp;longUrl='.$long_url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($ch);
  $res = json_decode($result, true);
  echo $res['data']['url']; // bit.ly/2PcG3Fg
  ?&gt;
  </code></pre>
  
  <p>However, how can this be done in the newer version? The above example uses API keys but it has been deprecated in favor of OAuth requests.</p>
  
  <p>How to shorten URL using Bitly <strong>v4</strong>?</p>