Vì một số lý do, tập lệnh của tôi ngừng hoạt động hôm nay. Khi tôi nhìn vào bảng điều khiển API, tôi vẫn còn 100% sử dụng. Bất kỳ ý tưởng? Họ có thay đổi cách xác thực không?Goo.gl URL Shortener Ngưng làm việc (php/curl)
function url_small($url)
{
//This is the URL you want to shorten
$longUrl = $url;
$apiKey = '#####HIDDEN######';
//Get API key from : http://code.google.com/apis/console/
$postData = array('longUrl' => $longUrl, 'key' => $apiKey);
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
//change the response json string to object
$json = json_decode($response);
curl_close($curlObj);
return $json->id;
}
đáp ứng
stdClass Object
(
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => usageLimits
[reason] => dailyLimitExceededUnreg
[message] => Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.
[extendedHelp] => https://code.google.com/apis/console
)
)
[code] => 403
[message] => Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.
)
)
Says ngay trong thông báo lỗi: ** Giới hạn hàng ngày cho Unauthenticated Sử dụng vượt quá. Tiếp tục sử dụng yêu cầu đăng ký. ** Tôi đoán bạn cần phải đăng ký, eh? –
@RobertHarvey yeah đó là những gì gây nhầm lẫn cho tôi. Nó đang chuyển khóa api cần phải là xác thực và sử dụng api cho ngày hôm nay là 0. – RichardW11
Kiểm tra [tại đây] (https://www.google.com/search?q=daily%20limit%20for%20unauthenticated%20use % 20%.% 20continued% 20use% 20requires% 20signup) và báo cáo lại. –