{"id":409,"date":"2010-11-04T01:00:02","date_gmt":"2010-11-03T16:00:02","guid":{"rendered":"http:\/\/blog.t-szk.com\/?p=409"},"modified":"2020-08-23T19:00:42","modified_gmt":"2020-08-23T10:00:42","slug":"phpbit-ly%e3%81%aeapi%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%a6url%e3%82%92%e7%9f%ad%e7%b8%ae%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/codaholic.org\/?p=409","title":{"rendered":"[PHP] bit.ly \u306e API \u3092\u5229\u7528\u3057\u3066 URL \u3092\u77ed\u7e2e\u3059\u308b"},"content":{"rendered":"<p>URL \u77ed\u7e2e\u306e\u305f\u3081\u306e\u30b3\u30fc\u30c9\u3092\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u4e0b\u8a18\u306b\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<pre><code class=\"language-php\">&lt;?php\n    $data = file_get_contents('http:\/\/api.bit.ly\/shorten?version=2.0.1&amp;login=YourUserName&amp;apiKey=YourAPIKey&amp;longUrl=https:\/\/codaholic.org\/&amp;format=xml');\n    $xml = simplexml_load_string($data);\n    echo $xml-&gt;results-&gt;nodeKeyVal-&gt;shortUrl;\n<\/code><\/pre>\n<p>blt.ly \u306e API \u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u307e\u305a\u4f1a\u54e1\u767b\u9332\u304c\u5fc5\u8981\u3067\u3059\u3002\u4f1a\u54e1\u767b\u9332\u3068\u3044\u3063\u3066\u3082\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u5165\u529b\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u7c21\u5358\u3067\u3059\u3002\u4f1a\u54e1\u767b\u9332\u3092\u3059\u308b\u3064 API Key \u3092\u5165\u624b\u3067\u304d\u307e\u3059\u3002\u3053\u306e API Key \u3092\u30b3\u30d4\u30fc&amp;\u30da\u30fc\u30b9\u30c8\u3067\u63a7\u3048\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u9001\u4fe1\u5148\u306f <code>http:\/\/api.bit.ly\/shorten<\/code> \u3067\u3059\u3002\u4e0a\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3001YourUserName \u3092\u4f1a\u54e1\u767b\u9332\u6642\u306b\u5165\u529b\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u540d\u306b\u3001YourAPIKey \u3092\u63a7\u3048\u305f API Key \u306b\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002long_url \u306b\u306f\u77ed\u7e2e\u3057\u305f\u3044URL\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002format \u306b\u306f\u3069\u306e\u5f62\u5f0f\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u3082\u3089\u3044\u305f\u3044\u306e\u304b\u6307\u5b9a\u3057\u307e\u3059\u3002\u30b5\u30f3\u30d7\u30eb\u306e\u5834\u5408\u306f xml \u3067\u8fd4\u5374\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u8fd4\u5374\u3055\u308c\u305f XML \u3092 <code>simplexml_load_string<\/code> \u95a2\u6570\u3067\u30d1\u30fc\u30b9\u3057\u3066\u3001\u77ed\u7e2e URL \u90e8\u5206\u3092\u53d6\u308a\u51fa\u305b\u3070\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u73fe\u5728\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f 3.0 \u306e\u3088\u3046\u306a\u306e\u3067\u3059\u304c\u30013.0 \u3060\u3068\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u9001\u4fe1\u65b9\u6cd5\u304c\u7570\u306a\u308b\u3088\u3046\u3067\u3059\u3002\u30b5\u30f3\u30d7\u30eb\u3067\u306f2.0.1\u3068\u3057\u3066\u3044\u307e\u3059\u304c\u30012010\u5e7411\u67084\u65e5\u73fe\u5728\u52d5\u4f5c\u78ba\u8a8d\u304c\u3067\u304d\u3066\u3044\u307e\u3059\u306e\u3067\u4eca\u306e\u3068\u3053\u308d\u306f\u554f\u984c\u306a\u304f\u5229\u7528\u51fa\u6765\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>URL \u77ed\u7e2e\u306e\u305f\u3081\u306e\u30b3\u30fc\u30c9\u3092\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u4e0b\u8a18\u306b\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4],"tags":[257,62,244],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gd1W-6B","_links":{"self":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/409"}],"collection":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=409"}],"version-history":[{"count":7,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/409\/revisions"}],"predecessor-version":[{"id":2487,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/409\/revisions\/2487"}],"wp:attachment":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}