{"id":2296,"date":"2016-07-20T06:20:02","date_gmt":"2016-07-19T21:20:02","guid":{"rendered":"http:\/\/aws2000.net\/?p=2296"},"modified":"2017-01-28T15:07:35","modified_gmt":"2017-01-28T06:07:35","slug":"%e8%b6%85%e7%b0%a1%e5%8d%98%ef%bc%81php%e3%81%a7%e3%80%81twitter%e3%81%ab%e7%94%bb%e5%83%8f%e4%bb%98%e3%81%8d%e3%83%84%e3%82%a4%e3%83%bc%e3%83%88%e3%82%92%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/aws2000.net\/?p=2296","title":{"rendered":"\u8d85\u7c21\u5358\uff01php\u3067\u3001twitter\u306b\u753b\u50cf\u4ed8\u304d\u30c4\u30a4\u30fc\u30c8\u3092\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/aws2000.net\/wp-content\/uploads\/2016\/07\/8537569665_3a3315e8fa_z-550x309.jpg\" alt=\"twitter\" width=\"550\" height=\"309\" class=\"alignnone size-medium wp-image-2305\" srcset=\"https:\/\/aws2000.net\/wp-content\/uploads\/2016\/07\/8537569665_3a3315e8fa_z-550x309.jpg 550w, https:\/\/aws2000.net\/wp-content\/uploads\/2016\/07\/8537569665_3a3315e8fa_z.jpg 640w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/p>\n<p>twitter\u306b\u753b\u50cf\u4ed8\u304d\u30c4\u30a4\u30fc\u30c8\u3092\u3059\u308b\u3001\u3044\u308f\u3086\u308b\u300cBOT\u300d\u3092\u4f5c\u308a\u305f\u3044\u3068\u601d\u3063\u3066\u3001\u8272\u3005\u3068\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>twitter\u7528\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u958b\u767a\u3059\u308b\u306b\u306f\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306b\u643a\u5e2f\u96fb\u8a71\u756a\u53f7\u3092\u767b\u9332\u3057\u3001<a href=\"https:\/\/apps.twitter.com\/\" target=\"_blank\">Application Management<\/a>\u3067\u958b\u767a\u8005\u7528\u306e\u767b\u9332\u3092\u3057\u3001API\u30ad\u30fc\u3084\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u306a\u3069\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>abraham\/twitteroauth \u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u753b\u50cf\u4ed8\u304d\u30c4\u30a4\u30fc\u30c8\u3092\u3059\u308b\u305f\u3081\u306e\u30b3\u30fc\u30c9\u306f\u3001\u8d85\u7c21\u5358\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3001\u30b5\u30fc\u30d0\u30fc\u306f\u3001Xserver\u3092\u4f7f\u3063\u305f\u306e\u3067\u3001abraham\/twitteroauth \u306f\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u307e\u305a\u3001\u3053\u3061\u3089\u304b\u3089\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/abraham\/twitteroauth\" target=\"_blank\">https:\/\/github.com\/abraham\/twitteroauth<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-2297\" src=\"\/\/aws2000.net\/wp-content\/uploads\/2016\/07\/1-550x398.gif\" alt=\"abraham\/twitteroauth\" width=\"550\" height=\"398\" \/><\/p>\n<p>twitteroauth-master.zip \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>twitteroauth-master.zip \u3092\u5c55\u958b\u3059\u308b\u3068\u3001twitteroauth-master\u30d5\u30a9\u30eb\u30c0\u306e\u4e2d\u306b\u3001\u3044\u304f\u3064\u304b\u306e\u30d5\u30a1\u30a4\u30eb\u3068 src\u30d5\u30a9\u30eb\u30c0\u3001tests\u30d5\u30a9\u30eb\u30c0\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2298\" src=\"\/\/aws2000.net\/wp-content\/uploads\/2016\/07\/2.gif\" alt=\"abraham\/twitteroauth\" width=\"122\" height=\"224\" \/><\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u3068src\u30d5\u30a9\u30eb\u30c0\u3092\u30b5\u30fc\u30d0\u30fc\u306e\u4efb\u610f\u306e\u5834\u6240\u306b\u30a2\u30c3\u30d7\u3057\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u305f\u3081\u306ephp\u30b3\u30fc\u30c9\u306f\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\r\n\r\n\/\/ \u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u8aad\u307f\u8fbc\u3080\r\n  require_once('twitteroauth\/autoload.php');\r\n  require_once('twitteroauth\/src\/TwitterOAuth.php');\r\n\r\n\/\/ \u30c4\u30a4\u30c3\u30bf\u30fc\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\r\n  define('consumer_key', 'API\u30ad\u30fc');\r\n  define('consumer_secret', 'API \u30b7\u30fc\u30af\u30ec\u30c3\u30c8');\r\n  define('access_token', '\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3');\r\n  define('access_token_secret', '\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3 \u30b7\u30fc\u30af\u30ec\u30c3\u30c8');\r\n\r\n  use Abraham\\TwitterOAuth\\TwitterOAuth;\r\n\r\n\/\/ \u30c4\u30a4\u30c3\u30bf\u30fc\u306b\u30a2\u30af\u30bb\u30b9\r\n  $connection = new TwitterOAuth(\r\n    consumer_key,\r\n    consumer_secret,\r\n    access_token,\r\n    access_token_secret\r\n  );\r\n\r\n\/\/ \u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3001\u305d\u306e\u30e1\u30c7\u30a3\u30a2ID\u3092\u5909\u6570\u306b\u683c\u7d0d\r\n  $media1 = $connection->upload('media\/upload', ['media' => '\u753b\u50cf\u30d5\u30a1\u30a4\u30eb1']);\r\n  $media2 = $connection->upload('media\/upload', ['media' => '\u753b\u50cf\u30d5\u30a1\u30a4\u30eb2']);\r\n\r\n\/\/ \u30c4\u30a4\u30fc\u30c8\u3059\u308b\u305f\u3081\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30bb\u30c3\u30c8\r\n  $parameters = [\r\n    'status' => '\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u5185\u5bb9140\u6587\u5b57\u4ee5\u5185',\r\n    'media_ids' => implode(',', [\r\n        $media1->media_id_string,\r\n        $media2->media_id_string\r\n        ])\r\n  ];\r\n\r\n\/\/ \u30c4\u30a4\u30fc\u30c8\u3092\u5b9f\u884c\r\n  $result = $connection->post('statuses\/update', $parameters);\r\n\r\n?&gt;<\/code><\/pre>\n<p>autoload.php \u3068 TwitterOAuth.php \u306b\u3001\u6b63\u3057\u304f\u30d1\u30b9\u3092\u901a\u305b\u3070\u3001\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n<p>\u6307\u5b9a\u3057\u305f\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u304c\u7121\u3044\u3068\u3001\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u6587\u5b57\u306e\u30c4\u30a4\u30fc\u30c8\u306f\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>BOT\u306b\u3059\u308b\u306a\u3089\u3001\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u6587\u5b57\u5217\u3084\u753b\u50cf\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306a\u3069\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u3057\u305f\u308a\u3001cron \u3067\u6307\u5b9a\u3057\u305f\u6642\u9593\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u81ea\u52d5\u5b9f\u884c\u3055\u305b\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u753b\u50cf\u4ed8\u304d\u306e\u30c4\u30a4\u30fc\u30c8\u306f\u3001\u81ea\u5206\u3067\u6700\u521d\u304b\u3089\u30b3\u30fc\u30c9\u3092\u66f8\u3053\u3046\u3068\u601d\u3046\u3068\u3001\u304b\u306a\u308a\u9762\u5012\u3067\u3059\u304c\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u3053\u3093\u306a\u306b\u7c21\u5358\u306b\u5b9f\u73fe\u3067\u304d\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>twitter\u306b\u753b\u50cf\u4ed8\u304d\u30c4\u30a4\u30fc\u30c8\u3092\u3059\u308b\u3001\u3044\u308f\u3086\u308b\u300cBOT\u300d\u3092\u4f5c\u308a\u305f\u3044\u3068\u601d\u3063\u3066\u3001\u8272\u3005\u3068\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002 twitter\u7528\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u958b\u767a\u3059\u308b\u306b\u306f\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u306b\u643a\u5e2f\u96fb\u8a71\u756a\u53f7\u3092\u767b\u9332\u3057\u3001Application Managem [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2305,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,9],"tags":[],"class_list":{"0":"post-2296","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-twitter","8":"category-9"},"_links":{"self":[{"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/posts\/2296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aws2000.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2296"}],"version-history":[{"count":12,"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/posts\/2296\/revisions"}],"predecessor-version":[{"id":3151,"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/posts\/2296\/revisions\/3151"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aws2000.net\/index.php?rest_route=\/wp\/v2\/media\/2305"}],"wp:attachment":[{"href":"https:\/\/aws2000.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aws2000.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aws2000.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}