再次!
我创建了一个嵌入在使用UrlShortener.Url.insert功能的电子表格的脚本。 我的客户希望能够让这个电子表格的新情况与同事分享。 我实现了这个功能,但是当我开始测试新的实例它原来,我必须使URL缩短API在我的谷歌开发者控制台。
我不知道如果我可以用我的脚本绕过这个体力劳动还是只有我能做的就是提供客户端的指令怎么办呢?
更新:桑迪好recomends使用UrlFetch.fetch()来获取短链接,但这样的代码:
function test_short_link() {
var options =
{
'longUrl': 'http://www.google.com/',
'muteHttpExceptions': true
};
var result = UrlFetchApp.fetch("https://www.googleapis.com/urlshortener/v1/url",
options);
Logger.log(result);
}
返回此:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: shortUrl",
"locationType": "parameter",
"location": "shortUrl"
}
],
"code": 400,
"message": "Required parameter: shortUrl"
}
}
貌似这个话题
而这个代码
function test_short_link() {
var options =
{
'longUrl': 'http://www.google.com/',
'muteHttpExceptions': true,
'method':'post'
};
var result = UrlFetchApp.fetch("https://www.googleapis.com/urlshortener/v1/url",
options);
Logger.log(result);
}
给我们带来:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "userRateLimitExceededUnreg",
"message": "User Rate Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "User Rate Limit Exceeded. Please sign up"
}
}