2017-06-07 44 views
0

我沒有編碼多年,所以請原諒我。我試着用下面的代碼以獲得來自估計API令牌,但得到這個錯誤返回:無法從Reckon API獲取令牌 - 返回SSL錯誤

「SSL證書問題:無法獲取本地頒發者證書」

<?php 
$code= $_GET['code']; 
$url = 'https://identity.reckon.com/connect/token'; 
$auth_creds = "CLIENTID:CLIENTSECRET"; 
$headers = array(
    "Content-Type: application/x-www-form-urlencoded", 
    "Authorization: Basic" . base64_encode($auth_creds)); 
$body = 'grant_type=authorization_code&code=' . $code . 
'&redirect_uri=http://localhost'; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); 
$response = curl_exec($ch); 
if($response === false)$response= curl_error($ch); 
curl_close($ch); 
echo $response; 
?> 

我遵循Reckon API oauth幫助文檔:https://reckon.helpdocsonline.com/reckon-api-authorisation-services

回答

0

我設法解決了這個問題。我不得不添加以下這行代碼: curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false); 但是當時我得到另一個錯誤「{」error「:」invalid_client「}」...「 這是由於我的客戶端ID和客戶端密碼編碼不正確。但現在,這是固定的,我有我的令牌和刷新令牌。

+0

你是怎麼改變你的客戶端ID和密碼的編碼的。我得到相同的invalid_client錯誤 – Brett