0

嗨,我正在尝试实现 oauth 协议并设法获得授权码,但是在请求令牌时,我发出的 curl 请求返回空白。

这是我到目前为止的代码

<?php
$code=$_GET["code"];
//URL of targeted site  
$baseurl = "http://okowsc.co.uk/oauth/request_token?grant_type=authorization_code&client_id=CLIENTHERE&client_secret=80e294010d50bc71c04b&code=";
$url="$baseurl" . "$code";
print "$url";

 $curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, "http://okowsc.co.uk/oauth/request_token");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec ($curl);
    curl_close ($curl);
    print "$result";

//$returnValue = json_decode('{"access_token":"1e36f6fd77f2f667099ef8f9a0bd332ca4b97831","expires_in":3600,"token_type":"bearer","scope":"","refresh_token":"d23dca2981dd11669501a0a3d2a5d00ef0f51c75"}', true);
$returnValue = json_decode($output, true);
//print_r ($returnValue);
//echo $returnValue[key($returnValue)];
//echo $returnValue[key($returnValue)];
//echo $returnValue[key($returnValue)];
echo $returnValue[key($returnValue)];
?>

请求令牌页面在进入浏览器时有效,它应该返回 {"access_token":" * **** ","expires_in":3600,"token_type":"bearer","scope":"","re​​fresh_token" :" * ** * **** "}" (盯着它作为一个 oauth 令牌)感谢您的任何回答

4

0 回答 0