again!
I created an embedded in spreadsheet script that use UrlShortener.Url.insert feature. My client wants to be able to make a new instances of this spreadsheet to share it with colleagues. I've implemented this feature, but when I begin to test new instance it's turned out that I have to enable URL Shortener API in my Google Developers Console.
I wonder if I can bypass this manual work using my script or only I can do is to provide client with instructions how to do it?
Update: Sandy Good recomends to use UrlFetch.fetch() to get the short link, but this code:
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);
}
returns this:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: shortUrl",
"locationType": "parameter",
"location": "shortUrl"
}
],
"code": 400,
"message": "Required parameter: shortUrl"
}
}
Looks like this topic
And this code
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);
}
bring us:
{
"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"
}
}