Paypal get access token with PHP cURL
<p>hello i'm using code used by other people who supposedly have gotten it to work and have gotten their token information retrieved. The code is as follows:</p>

<pre><code>$ch = curl_init();
$clientId = "myclientid";
$secret = "mysecret";

curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION , 6); //NEW ADDITION
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");

$result = curl_exec($ch);

if(empty($result))die("Error: No response.");
else
{
    $json = json_decode($result);
    print_r($json-&gt;access_token);
}

curl_close($ch); //THIS CODE IS NOW WORKING!
</code></pre>

<p>I retrieved this code from <a href="https://stackoverflow.com/questions/15729167/paypal-api-with-php-and-curl">Paypal API with PHP and cURL</a> and have seen it implemented in some others peoples code so i assume that it works. However i'm only receiving no response even though i am supplying the correct client id and secret (maybe a recent update has broken this code?).</p>

<p>The guide provided by Paypal on getting the access token is found here-> <a href="https://developer.paypal.com/docs/integration/direct/make-your-first-call/" rel="noreferrer">https://developer.paypal.com/docs/integration/direct/make-your-first-call/</a> 
however it demonstrates the solution in cURL and not through the PHP cURL extension so its alittle cryptic to me. Any help?</p>