[英]problem with urlshortener api when using file_get_contents()
我創建了他的代碼,但是當我將參數更改為另一個鏈接時,它似乎只能在google.com鏈接上起作用,file_get_contents返回false
function google_url_short($link)
{
$data = array('longUrl' => $link);
$context = [
'http' => [
'method' => 'post',
'header' => 'Content-Type:application/json',
'content' => '{"longUrl":"'.$link.'"}'
]
];
$context = stream_context_create($context);
$result = file_get_contents('https://content.googleapis.com/urlshortener/v1/url?alt=json&key=AIzaSyDqOQwOBE0gH0_yQuqVJlPFgvSdbgyppE', false, $context);
}
google_url_short('https://www.google.com');
從2018年3月30日開始,我們將拒絕對goo.gl URL Shorter的支持。 請參閱此博客文章以了解詳細的時間表和替代方法。
您應注意,Google URL Shortener API已停止使用,正在將Google URL Shortener 轉換為Firebase動態鏈接
他們已經開始調整API中的許多功能。 我懷疑您遇到的問題是由於這個原因。
您應該切換到FireBase動態鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.