Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tinyurl_getShortLink(url) {
- try {
- if (url == undefined) {
- throw 'url is empty or is not a valid url!'
- }
- let content = UrlFetchApp.fetch('https://tinyurl.com/api-create.php?url=' + encodeURI(url));
- if (content.getResponseCode() != 200) {
- return 'An error occured: [ ' + content.getContentText() + ' ]';
- }
- return content.getContentText();
- } catch (e) {
- return 'An error occured: [ ' + e + ' ]';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement