Joseph Bada Joseph Bada - 5 years ago 367
PHP Question

Infusionsoft OAuth callback SSL error PHP

my problem is this:

Ive went to developer.infusionsoft.com to get the PHP-SDK helper library for Infusionsoft API integration.
I installed it via composer. i have the vendor(folder)which, appears after composer finish.

over the tutorials, vendor folder is very significant so i think im on the right path of things

my code for using the api is this

function loadInfusionsoft($callback) {
$data = array();
$data['status'] = "unsuccessfull";
try {
$infusionsoft = new \Infusionsoft\Infusionsoft(array(
'clientId' => 'CLIENTID',
'clientSecret' => 'SECRETKEY',
'redirectUri' => $callback,
));
// If the serialized token is available in the session storage, we tell the SDK
// to use that token for subsequent requests.
if (isset($_SESSION['token'])) {
$infusionsoft->setToken(unserialize($_SESSION['token']));
}

// If we are returning from Infusionsoft we need to exchange the code for an
// access token.
if (isset($_GET['code']) and ! $infusionsoft->getToken()) {
$infusionsoft->requestAccessToken($_GET['code']);
}

if ($infusionsoft->getToken()) {
// Save the serialized token to the current session for subsequent requests
$_SESSION['token'] = serialize($infusionsoft->getToken());
} else {
$href = $infusionsoft->getAuthorizationUrl();
$data['status'] = "successfull";
$data["href"] = $href;
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
return $data;


please bear with me, i am new to this, so i have a vague clue on what is happening. i got this code on the infusionsoft tutorial(git). and on the middle of understanding things, i got an error.

cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)


i didn't get that error right away though. on what i understand,


  • it will skip all the if statements and will land on the else statement.

  • on else statement, i will be given an href link for the infusionsoft authentication. most probably an href value of
    <a>
    .

  • on the page, clicking on that link, will go to infusionsoft loggedin

  • after successful logged in, it will redirect to my localhost (because of the callback variable) with GET variables (which are scope, and code)

  • It will call this function again.

  • i believe it will enter the
    if isset($_GET['code'])
    statement

  • got the error

    cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

  • on my researches, i need a certificate.

  • on looking on the vendor folder(infusionsoft PHP SDK) i see that
    there is a
    cacert.pem
    file.. on my research, that is a
    certificate file

  • I searched how to use it but i always saw about crt and cert files.



and im stucked.

whats the next step? searched infusionsoft community but no luck.

i believe its not an infusionsoft issue but a mere misconfiguration on my end.
anyone?

Answer Source

just want to share. after few trials and errors.

its just really a simple error (problem is i am not quite knowledgeable to this)

on php.ini file, add the path to the cacert.pem like this.

curl.cainfo = "C:\path\to\cacert.pem"

note that curl.cainfo must have an absolute path.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download