{"id":4307,"date":"2014-03-25T00:16:46","date_gmt":"2014-03-24T15:16:46","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=4307"},"modified":"2015-07-14T16:54:21","modified_gmt":"2015-07-14T07:54:21","slug":"google-apps-scripturl-shortener-api%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e7%9f%ad%e7%b8%aeurl%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e8%87%aa%e4%bd%9c%e9%96%a2%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=4307","title":{"rendered":"[Google Apps Script]URL Shortener API\u3092\u4f7f\u3063\u3066\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308b\u81ea\u4f5c\u95a2\u6570"},"content":{"rendered":"<p><span style=\"color: #ff0000; font-weight: bold;\">2015\/7\/14 \u8ffd\u8a18\uff1a<\/span><\/p>\n<p>\u3044\u3064\u306e\u9593\u306b\u304bAPI\u306e\u547c\u3073\u51fa\u3057\u306bAPI\u30ad\u30fc\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f(\u30da\u30fc\u30b8\u4e0b\u90e8\u300c\u62e1\u5f35\u30b5\u30fc\u30d3\u30b9\u300d\u7248\u306f\u4e0d\u8981\u3067\u3059)\u3002<br \/>\nAPI\u30ad\u30fc\u306e\u53d6\u5f97\u65b9\u6cd5\u306f\u300c<a href=\"\/\/www.ka-net.org\/blog\/?p=5776\" title=\"goo.gl\u3067\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">goo.gl\u3067\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed<\/a>\u300d\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function getShortUrl(url){\r\n    var key = &quot;(API\u30ad\u30fc)&quot;;\r\n    var api_url = &quot;https:\/\/www.googleapis.com\/urlshortener\/v1\/url?key=&quot; + key;\r\n    var payload = '{&quot;longUrl&quot;:&quot;' + url + '&quot;}';\r\n    var options = {\r\n        &quot;contentType&quot;:&quot;application\/json&quot;,\r\n        &quot;method&quot;:&quot;post&quot;,\r\n        &quot;payload&quot;:payload\r\n    };\r\n    var res = UrlFetchApp.fetch(api_url, options);\r\n    return JSON.parse(res.getContentText()).id;\r\n}<\/pre>\n<hr \/>\n<p>\u300c<a href=\"\/\/www.ka-net.org\/office\/of38.html\" title=\"goo.gl\u3067\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308b(Office VBA)\" target=\"_blank\">goo.gl\u3067\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308b(Office VBA)<\/a>\u300d\u3067\u3082\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3059\u304c\u3001Google\u306e<a href=\"https:\/\/developers.google.com\/url-shortener\/v1\/getting_started\" title=\"Getting Started - URL Shortener API - Google Developers\" target=\"_blank\">URL Shortener API<\/a>\u3092\u4f7f\u3046\u3068\u3001\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3053\u306eAPI\u3092\u5229\u7528\u3057\u3066\u3001\u6307\u5b9a\u3057\u305fURL\u306e\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308b\u81ea\u4f5c\u95a2\u6570\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function getShortUrl(url){\r\n    var api_url = &quot;https:\/\/www.googleapis.com\/urlshortener\/v1\/url&quot;;\r\n    var payload = '{&quot;longUrl&quot;:&quot;' + url + '&quot;}';\r\n    var options = {\r\n        &quot;contentType&quot;:&quot;application\/json&quot;,\r\n        &quot;method&quot;:&quot;post&quot;,\r\n        &quot;payload&quot;:payload\r\n    };\r\n    var res = UrlFetchApp.fetch(api_url, options);\r\n    return JSON.parse(res.getContentText()).id;\r\n}<\/pre>\n<p>\u4e0b\u56f3\u306e\u3088\u3046\u306b\u30b7\u30fc\u30c8\u4e0a\u304b\u3089\u3001\u65b0\u3057\u3044 Google \u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u300c<a href=\"https:\/\/support.google.com\/drive\/answer\/3256501\" title=\"ISURL - \u30c9\u30e9\u30a4\u30d6 \u30d8\u30eb\u30d7\" target=\"_blank\">ISURL<\/a>\u300d\u95a2\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><textarea cols=60 rows=2 onclick=\"this.focus();this.select();\">=IF(ISURL($B2),getShortUrl($B2),&#34;URL\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002&#34;)<\/textarea><\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_10.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_10.jpg\" alt=\"GoogleAppsScript_10_10\" width=\"622\" height=\"168\" class=\"alignnone size-full wp-image-4308\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_10.jpg 622w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_10-300x81.jpg 300w\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<p>\u305f\u3060\u3057\u3001ISURL\u95a2\u6570\u306e\u4ed5\u69d8\u4e0a\u3001\u65e5\u672c\u8a9eURL\u306e\u5224\u5b9a\u306f\u6b63\u3057\u304f\u884c\u3048\u306a\u3044\u3088\u3046\u3067\u3059\u3002<br \/>\n(getShortUrl\u95a2\u6570\u81ea\u4f53\u306f\u65e5\u672c\u8a9eURL\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002)<\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_11.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_11.jpg\" alt=\"GoogleAppsScript_10_11\" width=\"532\" height=\"123\" class=\"alignnone size-full wp-image-4309\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_11.jpg 532w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/GoogleAppsScript_10_11-300x69.jpg 300w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/a><\/p>\n<p><span style=\"color: #ff0000; font-weight: bold;\">2014\/4\/1 \u8ffd\u8a18\uff1a<\/span><br \/>\n<a href=\"\/\/www.ka-net.org\/blog\/?p=4372\" title=\"[Google Apps Script]\u62e1\u5f35\u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u7528\u3059\u308b\u3002\" target=\"_blank\">\u62e1\u5f35\u30b5\u30fc\u30d3\u30b9<\/a>\u3092\u4f7f\u3046\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30b3\u30fc\u30c9\u3092\u77ed\u304f\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function getShortUrl(url){\r\n    return UrlShortener.Url.insert({longUrl:url}).id\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"2015\/7\/14 \u8ffd\u8a18\uff1a \u3044\u3064\u306e\u9593\u306b\u304bAPI\u306e\u547c\u3073\u51fa\u3057\u306bAPI\u30ad\u30fc\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f(\u30da\u30fc\u30b8\u4e0b\u90e8\u300c\u62e1\u5f35\u30b5\u30fc\u30d3\u30b9\u300d\u7248\u306f\u4e0d\u8981\u3067\u3059)\u3002 API\u30ad\u30fc\u306e\u53d6\u5f97\u65b9\u6cd5\u306f\u300cgoo.gl\u3067\u77ed\u7e2eURL\u3092\u53d6\u5f97\u3059\u308bVBA\u30de\u30af\u30ed\u300d\u3092\u3054\u53c2\u7167\u304f\u3060 [&hellip;]","protected":false},"author":1,"featured_media":7113,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[126],"tags":[],"class_list":["post-4307","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Google.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-17t","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4307"}],"version-history":[{"count":5,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4307\/revisions"}],"predecessor-version":[{"id":5831,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4307\/revisions\/5831"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7113"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}