{"id":1060,"date":"2011-09-10T23:15:55","date_gmt":"2011-09-10T14:15:55","guid":{"rendered":"http:\/\/codaholic.org\/?p=1060"},"modified":"2020-08-23T21:03:23","modified_gmt":"2020-08-23T12:03:23","slug":"phptwitter-api%e3%82%92%e5%88%a9%e7%94%a8%e3%81%97%e3%81%a6%e6%a4%9c%e7%b4%a2%e7%b5%90%e6%9e%9c%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/codaholic.org\/?p=1060","title":{"rendered":"[PHP] Twitter API \u3092\u5229\u7528\u3057\u3066\u691c\u7d22\u7d50\u679c\u3092\u53d6\u5f97\u3059\u308b"},"content":{"rendered":"<p>Twitter\u306b\u306f\u691c\u7d22\u6a5f\u80fd\u304c\u3042\u308a\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u30c4\u30a4\u30fc\u30c8\u3092\u691c\u7d22\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u8208\u5473\u306e\u3042\u308b\u30ad\u30fc\u30ef\u30fc\u30c9\u3084\u30cf\u30c3\u30b7\u30e5\u30bf\u30b0\u3001URL\u7b49\u3067\u691c\u7d22\u3059\u308b\u3068\u9762\u767d\u3044\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u691c\u7d22\u7d50\u679c\u3092PHP\u3092\u5229\u7528\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4e0b\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u30ad\u30fc\u30ef\u30fc\u30c9\u300c\u30d6\u30ed\u30c3\u30b3\u30ea\u30fc\u300d\u3067Twitter\u3092\u691c\u7d22\u3057\u305f\u6642\u306e\u691c\u7d22\u7d50\u679c\u3092\u53d6\u5f97\u3057\u3066var_dump\u95a2\u6570\u3067\u4e2d\u8eab\u3092\u8868\u793a\u305b\u307e\u3059\u3002\u306a\u304a\u3001JSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u306e\u30c7\u30b3\u30fc\u30c9\u306b<a href=\"http:\/\/pear.php.net\/pepr\/pepr-proposal-show.php?id=198\" target=\"_blank\" rel=\"noopener noreferrer\">Services_JSON<\/a>\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n    include 'JSON.php';\n\n    $url = 'http:\/\/search.twitter.com\/search.json?q=' . urlencode('\u30d6\u30ed\u30c3\u30b3\u30ea\u30fc');\n    $response = file_get_contents($url);\n\n    $json = new Services_JSON;\n    var_dump($json-&gt;decode($response));\n?&gt;\n<\/code><\/pre>\n<p>\u9577\u3044\u306e\u3067\u7e70\u308a\u8fd4\u3055\u308c\u3066\u3044\u308b\u7b87\u6240\u306f\u7701\u7565\u3057\u3066\u3042\u308a\u307e\u3059\u304c\u3001\u4e0b\u8a18\u304c\u691c\u7d22\u7d50\u679c\u3068\u3057\u3066\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092var_dump\u95a2\u6570\u3067\u51fa\u529b\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u4e0b\u8a18\u306e\u5185\u5bb9\u3092\u898b\u308b\u3068\u3001results\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u7d50\u679c\u306e\u914d\u5217\u304c15\u4ef6\u5165\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre><code>object(stdClass)#2 (11) {\n  [\"completed_in\"]=&gt;\n  float(0.171)\n  [\"max_id\"]=&gt;\n  float(1.12510849201E+17)\n  [\"max_id_str\"]=&gt;\n  string(18) \"112510849201086465\"\n  [\"next_page\"]=&gt;\n  string(90) \"?page=2&amp;max_id=112510849201086465&amp;q=%E3%83%96%E3%83%AD%E3%83%83%E3%82%B3%E3%83%AA%E3%83%BC\"\n  [\"page\"]=&gt;\n  int(1)\n  [\"query\"]=&gt;\n  string(54) \"%E3%83%96%E3%83%AD%E3%83%83%E3%82%B3%E3%83%AA%E3%83%BC\"\n  [\"refresh_url\"]=&gt;\n  string(85) \"?since_id=112510849201086465&amp;q=%E3%83%96%E3%83%AD%E3%83%83%E3%82%B3%E3%83%AA%E3%83%BC\"\n  [\"results\"]=&gt;\n  array(15) {\n    [0]=&gt;\n    object(stdClass)#3 (14) {\n      [\"created_at\"]=&gt;\n      string(31) \"Sat, 10 Sep 2011 13:00:51 +0000\"\n      [\"from_user\"]=&gt;\n      string(8) \"to_kage_\"\n      [\"from_user_id\"]=&gt;\n      int(397060228)\n      [\"from_user_id_str\"]=&gt;\n      string(9) \"397060228\"\n      [\"geo\"]=&gt;\n      NULL\n      [\"id\"]=&gt;\n      float(1.12510849201E+17)\n      [\"id_str\"]=&gt;\n      string(18) \"112510849201086465\"\n      [\"iso_language_code\"]=&gt;\n      string(2) \"ja\"\n      [\"metadata\"]=&gt;\n      object(stdClass)#4 (1) {\n        [\"result_type\"]=&gt;\n        string(6) \"recent\"\n      }\n      [\"profile_image_url\"]=&gt;\n      string(63) \"http:\/\/a0.twimg.com\/profile_images\/1517135956\/Image2_normal.png\"\n      [\"source\"]=&gt;\n      string(86) \"&lt;a href=\"http:\/\/twtr.jp\" rel=\"nofollow\"&gt;Keitai Web&lt;\/a&gt;\"\n      [\"text\"]=&gt;\n      string(73) \"\u30b5\u30c9\u30eb\u30d6\u30ed\u30c3\u30b3\u30ea\u30fc\u306e\u72af\u4eba\u306f\u6771\u5927\u751f\u3058\u3083\u306a\u3044\u3079w \u78ba\u304bww\"\n      [\"to_user_id\"]=&gt;\n      NULL\n      [\"to_user_id_str\"]=&gt;\n      NULL\n    }\n    [1]=&gt;\n    object(stdClass)#5 (14) {\n      [\"created_at\"]=&gt;\n      string(31) \"Sat, 10 Sep 2011 13:00:46 +0000\"\n      [\"from_user\"]=&gt;\n      string(13) \"favstar50_ja2\"\n      [\"from_user_id\"]=&gt;\n      int(252800039)\n      [\"from_user_id_str\"]=&gt;\n      string(9) \"252800039\"\n      [\"geo\"]=&gt;\n      NULL\n      [\"id\"]=&gt;\n      float(1.12510828485E+17)\n      [\"id_str\"]=&gt;\n      string(18) \"112510828485419009\"\n      [\"iso_language_code\"]=&gt;\n      string(2) \"ja\"\n      [\"metadata\"]=&gt;\n      object(stdClass)#6 (1) {\n        [\"result_type\"]=&gt;\n        string(6) \"recent\"\n      }\n      [\"profile_image_url\"]=&gt;\n      string(72) \"http:\/\/a2.twimg.com\/profile_images\/1277076129\/twitterAvatar50_normal.png\"\n      [\"source\"]=&gt;\n      string(114) \"&lt;a href=\"http:\/\/sites.google.com\/site\/yorufukurou\/\" rel=\"nofollow\"&gt;YoruFukurou&lt;\/a&gt;\"\n      [\"text\"]=&gt;\n      string(413) \"RT @mini_humbucker: \u3010\u6771\u5927\u3011\u30b5\u30c9\u30eb\u306b\u30d6\u30ed\u30c3\u30b3\u30ea\u30fc\u3010\u4eac\u5927\u3011\u30b5\u30c9\u30eb\u304c\u6298\u7530\u5148\u751f\u3010\u962a\u5927\u3011\u30b5\u30c9\u30eb\u306bGentoo\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3010\u7b51\u6ce2\u5927\u3011\u30b5\u30c9\u30eb\u306b\u5973\u88c5\u7528\u30a6\u30a3\u30c3\u30b0\u3010\u82b8\u5927\u3011\u300c\u30b5\u30c9\u30eb\u3068\u3044\u3046\u6982\u5ff5\u3092\u58ca\u3057\u305f\u304b\u3063\u305f\u300d\u81ea\u8ee2\u8eca12\u53f0\u3092\u4f7f\u3063\u305f\u5de8\u5927\u30aa\u30d6\u30b8\u30a7\u3010\u97f3\u5927\u3011\u30b5\u30c9\u30eb\u3092\u53d6\u308a\u5916\u3057\u3066\u7a74\u3092\u7a7a\u3051\u30d5\u30ec\u30fc\u30e0\u3092\u7b1b\u306b\u3010F\u30e9\u30f3\u3011\u666e\u901a\u306b\u30b5\u30c9\u30eb\u7121\u3044\"\n      [\"to_user_id\"]=&gt;\n      NULL\n      [\"to_user_id_str\"]=&gt;\n      NULL\n    }\n\n    ...\u7e70\u308a\u8fd4\u3057...\n\n    [14]=&gt;\n    object(stdClass)#31 (14) {\n      [\"created_at\"]=&gt;\n      string(31) \"Sat, 10 Sep 2011 12:59:46 +0000\"\n      [\"from_user\"]=&gt;\n      string(7) \"crevavo\"\n      [\"from_user_id\"]=&gt;\n      int(91839471)\n      [\"from_user_id_str\"]=&gt;\n      string(8) \"91839471\"\n      [\"geo\"]=&gt;\n      NULL\n      [\"id\"]=&gt;\n      float(1.12510574793E+17)\n      [\"id_str\"]=&gt;\n      string(18) \"112510574792937473\"\n      [\"iso_language_code\"]=&gt;\n      string(2) \"ja\"\n      [\"metadata\"]=&gt;\n      object(stdClass)#32 (1) {\n        [\"result_type\"]=&gt;\n        string(6) \"recent\"\n      }\n      [\"profile_image_url\"]=&gt;\n      string(65) \"http:\/\/a2.twimg.com\/profile_images\/1525155179\/marukyuu_normal.png\"\n      [\"source\"]=&gt;\n      string(114) \"&lt;a href=\"http:\/\/sites.google.com\/site\/yorufukurou\/\" rel=\"nofollow\"&gt;YoruFukurou&lt;\/a&gt;\"\n      [\"text\"]=&gt;\n      string(413) \"RT @mini_humbucker: \u3010\u6771\u5927\u3011\u30b5\u30c9\u30eb\u306b\u30d6\u30ed\u30c3\u30b3\u30ea\u30fc\u3010\u4eac\u5927\u3011\u30b5\u30c9\u30eb\u304c\u6298\u7530\u5148\u751f\u3010\u962a\u5927\u3011\u30b5\u30c9\u30eb\u306bGentoo\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3010\u7b51\u6ce2\u5927\u3011\u30b5\u30c9\u30eb\u306b\u5973\u88c5\u7528\u30a6\u30a3\u30c3\u30b0\u3010\u82b8\u5927\u3011\u300c\u30b5\u30c9\u30eb\u3068\u3044\u3046\u6982\u5ff5\u3092\u58ca\u3057\u305f\u304b\u3063\u305f\u300d\u81ea\u8ee2\u8eca12\u53f0\u3092\u4f7f\u3063\u305f\u5de8\u5927\u30aa\u30d6\u30b8\u30a7\u3010\u97f3\u5927\u3011\u30b5\u30c9\u30eb\u3092\u53d6\u308a\u5916\u3057\u3066\u7a74\u3092\u7a7a\u3051\u30d5\u30ec\u30fc\u30e0\u3092\u7b1b\u306b\u3010F\u30e9\u30f3\u3011\u666e\u901a\u306b\u30b5\u30c9\u30eb\u7121\u3044\"\n      [\"to_user_id\"]=&gt;\n      NULL\n      [\"to_user_id_str\"]=&gt;\n      NULL\n    }\n  }\n  [\"results_per_page\"]=&gt;\n  int(15)\n  [\"since_id\"]=&gt;\n  int(0)\n  [\"since_id_str\"]=&gt;\n  string(1) \"0\"\n}\n<\/code><\/pre>\n<p>\u3053\u306e\u7d50\u679c\u304b\u3089\u305d\u308c\u305e\u308c\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30cd\u30fc\u30e0\u3001\u30c4\u30a4\u30fc\u30c8\u672c\u6587\u3001\u6295\u7a3f\u65e5\u6642\u3001\u30a2\u30a4\u30b3\u30f3\u753b\u50cf\u306eURL\u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002\u305d\u3053\u3067\u30b3\u30fc\u30c9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u306715\u4ef6\u306e\u30c4\u30a4\u30fc\u30c8\u305d\u308c\u305e\u308c\u306e\u60c5\u5831\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n    include 'JSON.php';\n\n    $url = 'http:\/\/search.twitter.com\/search.json?q=' . urlencode('\u30d6\u30ed\u30c3\u30b3\u30ea\u30fc');\n    $response = file_get_contents($url);\n\n    $json = new Services_JSON;\n    $data = $json-&gt;decode($response);\n\n    foreach($data-&gt;results as $value){\n        print $value-&gt;from_user . '&lt;br \/&gt;';\n        print $value-&gt;text . '&lt;br \/&gt;';\n        print $value-&gt;created_at . '&lt;br \/&gt;';\n        print $value-&gt;profile_image_url . '&lt;br \/&gt;';\n        print '&lt;br \/&gt;';\n    }\n<\/code><\/pre>\n<p><a href=\"https:\/\/dev.twitter.com\/docs\/api\/1\/get\/search\" target=\"_blank\" rel=\"noopener noreferrer\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u3088\u308b\u3068GET\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3059\u308b\u969b\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u4ed8\u52a0\u3059\u308b\u3053\u3068\u3067\u4e00\u5ea6\u306b\u53d6\u5f97\u3059\u308b\u4ef6\u6570\u3092\u5897\u3084\u3057\u305f\u308a\u3001\u691c\u7d22\u7d50\u679c\u3092\u7d9a\u304d\u3092\u53d6\u5f97\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002\u305f\u3060\u904e\u53bb\u306e\u5168\u3066\u306e\u30c4\u30a4\u30fc\u30c8\u3092\u5168\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u3088\u3046\u306a\u306e\u3067\u3001\u5206\u6790\u30c4\u30fc\u30eb\u3092\u4f5c\u308a\u305f\u3044\u5834\u5408\u306f\u81ea\u5206\u3067DB\u3092\u7528\u610f\u3057\u3066\u4fdd\u5b58\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Twitter\u306b\u306f\u691c\u7d22\u6a5f\u80fd\u304c\u3042\u308a\u6307\u5b9a\u3057\u305f\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u30c4\u30a4\u30fc\u30c8\u3092\u691c\u7d22\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u8208\u5473\u306e\u3042\u308b\u30ad\u30fc\u30ef\u30fc\u30c9\u3084\u30cf\u30c3\u30b7\u30e5\u30bf\u30b0\u3001URL\u7b49\u3067\u691c\u7d22\u3059\u308b\u3068\u9762\u767d\u3044\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u691c\u7d22\u7d50\u679c\u3092PHP\u3092\u5229\u7528\u3057\u3066\u53d6\u5f97\u3057\u307e [&hellip;]<\/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":[39,4,34],"tags":[257,244,256],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gd1W-h6","_links":{"self":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/1060"}],"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=1060"}],"version-history":[{"count":8,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/1060\/revisions"}],"predecessor-version":[{"id":2518,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/1060\/revisions\/2518"}],"wp:attachment":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}