API Response = null

Hey all,
I have been using the following PHP code to request user data via the Patreon API for about half a year now.

require_once(‘Patreon/src/patreon.php’);

use Patreon\API;
use Patreon\OAuth;

$url = ‘api.patreon.com/oauth2/token’;
$data = array(
‘code’ => $code,
‘grant_type’ => “authorization_code”,
‘client_id’ => “xx”,
‘client_secret’ => “xx”,
‘redirect_uri’ => “xx”);

$response = json_decode(httpPost($url ,$data));
$accessToken = $response->access_token;
$api_client = new Patreon\API($accessToken);

$patron_response = $api_client->fetch_user();
$patron = $patron_response[‘data’];

function httpPost($url, $data)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}

Where the using statements are from this project https://github.com/Patreon/patreon-php

But since about 1 day I am not able to request data anymore from the API.
The response object I receive is null.

Did anything change that I am not aware of ?

After debugging I found that the response i get from the OAuth2 is:

301 Moved Permanently

301 Moved Permanently


nginx/1.10.1 ' (length=185)

When requesting the tokens in get_tokens() in OAuth.php

So i guess it is moved ?

I think the api is now redirecting me to the https version of the website which leaves me with the following error:

cUrl error (#60): SSL certificate problem: unable to get local issuer certificate

Hey there @RvRooijen - we had an infrastructure change around HTTPS that caused unexpected issues for many libraries - we’ve rolled back the change temporarily. When we bring it back it will return it with lots of communication in this forum.

In addition to what @tal said, you can add

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

to make curl follow redirects. It’s in general a very good idea to do.

1 Like