向GOOGLE URL Shorteners API发出POST请求

问题描述 投票:0回答:1

我把api_key放在哪里?

我想添加我的API KEY,但它没有选项或我该怎么做,除了它没有API密钥我得到403限制超出错误

import requests
import json
url="https://in.yahoo.com/?p=us"
post_url = 'https://www.googleapis.com/urlshortener/v1/url'
payload = {'longUrl': url}
headers = {'content-type': 'application/json'}
r = requests.post(post_url, data=json.dumps(payload), headers=headers)
print (r.text)
python api python-requests google-url-shortener
1个回答
0
投票

正如the docs for the Google URL Shortener service所说:

从2018年3月30日开始,我们将拒绝支持goo.gl网址缩短。有关详细的时间表和备选方案,请参阅this blog post

如果您点击博客文章的链接,它会解释详细信息,但相关部分是:

从2018年5月30日开始,只有在今天之前访问过URL Shortener API的项目才能创建短链接。

所以,你可以做什么?

谷歌显然希望你切换到他们新的和改进的功能,Firebase Dynamic Links

要创建新的短链接,我们建议使用FDL API。 FDL短链接将自动检测用户的平台,并根据需要将用户发送到网络或您的应用程序。

他们提供migration support

对于那些不想或不愿意这样做的人来说,最好的选择是他们为goo.gl网站的消费者推荐的相同内容:

如果您想创建新的短链接,我们建议您查看Bitly和Ow.ly等热门服务作为替代方案。

请注意,BitlyOw.ly都有API。它们与Goo.gl有些相似 - 肯定比FDL更接近但不完全相同。

© www.soinside.com 2019 - 2024. All rights reserved.