0

From this snippet of code using the Oauth2 access_token:

$acsToken = json_decode($client->getAccessToken())->{'access_token'};
$arrHeader = array('Content-Type'=>'application/json', 'Authorization'=>'Bearer '.$acsToken);

$ch = curl_init( 'https://www.googleapis.com/fusiontables/v1/query?sql=SELECT%20UserID%20FROM%201DGQPfPkjgcNVUc3ndplxNBlET9TlwoVcQw5_jVA');
curl_setopt( $ch, CURLOPT_HTTPHEADER, $arrHeader);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );

if($response === false){
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo "<br /> response: ".$response; 
}

This is what is returned.

response: { "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceededUnreg", "message": "Daily Limit Exceeded. Please sign up", "extendedHelp": "https://code.google.com/apis/console" } ], "code": 403, "message": "Daily Limit Exceeded. Please sign up" } }

According to the api Console I have had 50 requests in the past 28 days. The maximum limit for fusion tables is 25,000 per day. so I shouldn't be over the limit.

I have not use cURL before. Is my cURL request malformed?

4

1 回答 1

0

您需要将 API 密钥添加为调用key请求的第二个参数。

https://www.googleapis.com/fusiontables/v1/query?sql=<query>&key=<your API key>

您可以在Google API 控制台的“API 访问”选项卡上找到您的 API 密钥。

于 2012-08-28T14:19:13.503 回答