我有一些麻煩,從得到的訪問令牌:的oauth2 PHP沒有數據返回
api.hybrid.ru/token
這個API文檔是俄羅斯(Link),它基本上是說:
Headers
POST /token HTTP/1.1
Host: api.hybrid.ru
Content-Type: application/x-www-form-urlencoded
Data:
grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}
我有有效的client_id和client_secret(hybrid.ru techs給了我那些),它甚至不會返回錯誤信息。 我用捲曲還有我的代碼:
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
$ch = curl_init();
$url = "https://www.api.hybrid.ru/token";
$post_data = array(
'grant_type'=> 'client_credentials',
'client_id'=>'********',
'client_secret'=>'********'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"POST /token HTTP/1.1",
'Content-Type: application/x-www-form-urlencoded',
"host: api.hybrid.ru"
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POSTREDIR, 3);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
?>
我想,如果在CLIENT_ID或client_secret API一些錯誤至少應該返回一些錯誤信息。
還有一個問題,client_secret是否包含字符「=」?他們給了我client_secret後面的「=」號。無論如何,有或沒有角色它不會返回任何數據。
任何幫助?
更新1
以下洛娜·米切爾的回答後,我得到這個消息:
Array (
[url] => https://api.hybrid.ru/Views/Errors/DefaultError.cshtml?aspxerrorpath=/
[content_type] => text/html; charset=utf-8 [http_code] => 500 [header_size] => 483
[request_size] => 440
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 1
[total_time] => 3.853833
[namelookup_time] => 0.972059
[connect_time] => 1.178887
[pretransfer_time] => 1.406303
[size_upload] => 479
[size_download] => 1763
[speed_download] => 457
[speed_upload] => 124
[download_content_length] => 1763
[upload_content_length] => 479
[starttransfer_time] => 1.612792 [redirect_time] => 2.028607
[redirect_url] =>
[primary_ip] => 212.8.236.42
[certinfo] => Array ()
[primary_port] => 443
[local_ip] => 162.214.7.244
[local_port] => 46088
)
HTTP/1.1 100 Continue HTTP/1.1
302 Found
Date: Wed, 26 Jul 2017 16:47:47 GMT
Content-Length: 166
Connection: keep-alive
Location: /Views/Errors/DefaultError.cshtml?aspxerrorpath=/
Server: Hybrid Web Server HTTP/1.1 100 Continue HTTP/1.1 500 Internal Server
Error
Date: Wed, 26 Jul 2017 16:47:49 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1763
Connection: keep-alive
Cache-Control: private
X-AspNet-Version: 4.0.30319
Server: Hybrid Web Server
後的任何想法?
你試圖使用telnet發送POST數據看,如果你得到任何迴應? – Dimi
這是關於第一次聽證會telnet,我跟着Lorna的回答,我可能會去關於這個混合的電子郵件,如果他們說問題在我身邊,我會嘗試你的方式,但沒有想法如何telnet可以給我任何不同的答案,如果你可以很好 – temo