我已经编写了CURL代码,用于显示排行榜中的游戏分数,但显示错误。
Array
阵 ( [错误] =>排列 ( [errors] =>排列 ( [0] =>排列 ( [domain] =>全球 [reason] =>需要 [message] =>要求登录 [locationType] =>头 [location] =>授权 )
)
[code] => 401
[message] => Login Required
)
我无法用这个实现Oauth2代码.....我的卷曲代码如下。请帮忙。
CODE:
<?php
if (!function_exists("curl_get")) {`enter code here`
function curl_get($kix) {
$header = array( 'Accept: application/json', 'Content-Type: multipart/form-data', 'Expect:' );
$agent = "Best Runs API/PHP (App ..............)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $kix);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'http://...../');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$html = curl_exec($ch);
curl_close($ch);
return $html;
}
}
$html = @curl_get("https://www.googleapis.com/games/v1/leaderboards/leadeboardID");
$json = json_decode($html,true);
echo $json;
echo "<pre>";
print_r($json);
echo "</pre>";
?>
答案 0 :(得分:0)
您应该在项目中使用Google PHP Api Library。 https://github.com/google/google-api-php-client