Rest API PHP merch/client login fails / returns empty with cURL

Piszi
Contributor
Contributor

Hello,

 

We set up an express checkout for our client which worked fine until a couple of days ago. Since than we can't check if transaction is ok or failed because the cURL login/auth fails(i think).

 

this was our cURL code which worked:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://paypal.com/v1/oauth2/token');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'CLIENT_ID : SECRET');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
$result = curl_exec($ch)

If I check $result it is empty and if I print out curl_errno than its 0 and curl_error is empty.

So I checked our server with your TLS test and it passed so I edited my code to this

 

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://paypal.com/v1/oauth2/token');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'CLIENT_ID : SECRET');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
$result = curl_exec($ch);

But the result is the same

than I downloaded the pem file from your github example and uploaded to our server and added the 

curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');

line to my code, but the result is still the same

than just for fun I removed header, false and added this line

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Accept-Language: en_US'));

But the result is still the same

 

What could be the problem?

Or is it possible that the initial login/auth renturns empty if its OK? because than I have to remove checking the $result from my code.

Obviously the CLIENT_ID and SECRET in my code is the real one from my app but I didn't wanted to post it here.

 

 

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.