php中需要google Oauth 2代码才能显示排行榜的游戏分数

I have written the CURL code for displaying game scores from a leaderboard but shows an error.


Array

Array ( [error] => Array ( [errors] => Array ( [0] => Array ( [domain] => global [reason] => required [message] => Login Required [locationType] => header [location] => Authorization )

            )

        [code] => 401
        [message] => Login Required
    )

I cannot implement the Oauth2 code with this .....my curl code is below. Please help.

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>";
?>

You should use Google PHP Api Library in your project. https://github.com/google/google-api-php-client