php - 使用 file_get_contents() 时 urlshortener api 的问题
问题描述
我创建了他的代码,但是当我将参数更改为另一个链接时,它似乎只适用于 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');
解决方案
Starting March 30, 2018, we will be turning down support for goo.gl URL shortener. Please see this blog post for detailed timelines and alternatives.
You should be aware that the Google URL Shortener API has been discontinued Transitioning Google URL Shortener to Firebase Dynamic Links
They have already begun tuning down a number of the features within the API. I suspect the issue you are having is due to that.
You should switch to FireBase Dynamic links
推荐阅读
- c++ - 如何为通用模板类设置默认参数
- sql - 如何:Oracle 解析函数返回行
- python - 对“pandas.core.series.Series”进行排序,使最大值位于中心
- rust - Rust 中“缓存代理”的正确所有权?
- .net - 当请求包含波浪号 ('~') 时,IIS 8.5 - 404 响应
- docker - Kubernetes Multus:不同节点上的 pod 之间没有 macvlan 连接(无法 ping)
- google-cloud-platform - 在 Google Cloud 中具有所有者角色的用户在使用 Gmail Api 时会收到 403
- arrays - 包含整数“0”的 PowerShell 数组与“^(0|3010)$”不匹配
- react-native - 如何更改 expo-av 中的视频显示方向?
- python - 在 Thonny IDE 中注释代码的键盘快捷键