{"id":1795,"date":"2010-10-15T08:35:55","date_gmt":"2010-10-14T23:35:55","guid":{"rendered":"http:\/\/www.studioeth.net\/ethBlog\/?p=796"},"modified":"2010-10-15T08:35:55","modified_gmt":"2010-10-14T23:35:55","slug":"%e7%89%b9%e5%ae%9a%e3%81%ae%e3%82%ad%e3%83%bc%e3%83%af%e3%83%bc%e3%83%89%e3%82%92%e5%90%ab%e3%82%80%e3%83%84%e3%82%a4%e3%83%bc%e3%83%88%e3%82%92%e3%81%97%e3%81%9f%e4%ba%ba%e3%82%92follow%e3%81%99","status":"publish","type":"post","link":"https:\/\/inage.ksd6700.net\/?p=1795","title":{"rendered":"\u7279\u5b9a\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u542b\u3080\u30c4\u30a4\u30fc\u30c8\u3092\u3057\u305f\u4eba\u3092Follow\u3059\u308bTwitter Bot\u3092\u3064\u304f\u3063\u3066\u307f\u305f"},"content":{"rendered":"<p><h4>\u521d\u671f\u8a2d\u5b9a<\/h4>\n<p>OAuth\u306e\u8a2d\u5b9a\u306f\u30b0\u30b0\u308b\u3068\u3044\u308d\u3044\u308d\u51fa\u3066\u304f\u308b\u306e\u3067\u7701\u7565\u3002<br \/>\n<a href=\"http:\/\/www.google.co.jp\/search?hl=ja&amp;q=oauth+twitter+php\" >http:\/\/www.google.co.jp\/search?hl=ja&amp;q=oauth+twitter+php<\/a><\/p>\n<h4>Bot\u4f5c\u6210<\/h4>\n<p>PHP\u3067\u66f8\u3044\u3066\u3044\u307e\u3059\u3002Twitter\u672c\u5bb6\u306eAPI\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u304b\u306a\u308a\u5145\u5b9f\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u3059\u3093\u306a\u308a\u3067\u304d\u305f\u3002<br \/>\nJSON\u3068\u304bPHP\u3068\u304b\u7d20\u4eba\u3060\u3063\u305f\u3051\u3069\u3001\u7279\u306b\u96e3\u3057\u304f\u306a\u304b\u3063\u305f\u3002<\/p>\n<div class=\"codecolorer-container php default\" style=\"overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;\">\n<div class=\"php codecolorer\" style=\"padding:5px;font:normal 12px\/1.4em Monaco, Lucida Console, monospace;white-space:nowrap\">&nbsp;<span style=\"color: #b1b100;\">require_once<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">&quot;twitteroauth.php&quot;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ OAuth\u8a2d\u5b9a\uff08\u7701\u7565\uff09<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ \u767a\u8a00\u3092\u884c\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u6307\u5b9a<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #000088;\">$method<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000ff;\">&quot;friendships\/create&quot;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ TwitterOAuth\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$twitter<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000000; font-weight: bold;\">new<\/span> TwitterOAuth<span style=\"color: #009900;\">&#40;<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$consumer_key<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #000088;\">$consumer_secret<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #000088;\">$oauth_token<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #000088;\">$oauth_token_secret<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ \u691c\u7d22\u3059\u308b<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$jsonurl<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #0000ff;\">&quot;http:\/\/search.twitter.com\/search.json?q=URL\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u30ad\u30fc\u30ef\u30fc\u30c9&quot;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ \u2191\u30d1\u30b9\u304c\u901a\u3063\u3066\u3044\u308b\u304b\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u4e0a\u8a18URL\u3092\u5165\u529b\u3057\u3066\u78ba\u8a8d\u3059\u308b\u3002json\u3092Firefox\u4e0a\u3067\u898b\u308b\u306e\u306b\u306f\u3001&lt;a href=&quot;http:\/\/www.moongift.jp\/2009\/08\/jsonview\/&quot; target=&quot;_blank&quot;&gt;JSONView&lt;\/a&gt;\u304c\u4fbf\u5229<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$json<\/span> <span style=\"color: #339933;\">=<\/span> <a href=\"http:\/\/www.php.net\/file_get_contents\"><span style=\"color: #990000;\">file_get_contents<\/span><\/a><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000088;\">$jsonurl<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #009900; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">,<\/span><span style=\"color: #009900; font-weight: bold;\">null<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$json_output<\/span> <span style=\"color: #339933;\">=<\/span> <a href=\"http:\/\/www.php.net\/json_decode\"><span style=\"color: #990000;\">json_decode<\/span><\/a><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000088;\">$json<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #b1b100;\">foreach<\/span> <span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$json_output<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>results <span style=\"color: #b1b100;\">as<\/span> <span style=\"color: #000088;\">$result<\/span> <span style=\"color: #009900;\">&#41;<\/span><br \/>\n&nbsp;<span style=\"color: #009900;\">&#123;<\/span><br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ echo &quot;{$result-&amp;gt;from_user}\\n&quot;; <\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ \u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$parameters<\/span> <span style=\"color: #339933;\">=<\/span> <a href=\"http:\/\/www.php.net\/array\"><span style=\"color: #990000;\">array<\/span><\/a><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #0000ff;\">&quot;id&quot;<\/span> <span style=\"color: #339933;\">=&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span> <span style=\"color: #000088;\">$result<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>from_user<span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #666666; font-style: italic;\">\/\/ Twitter\u306b\u30d5\u30a9\u30ed\u30fc\u8981\u6c42\u3092POST<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$response<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000088;\">$twitter<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>post<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000088;\">$method<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #000088;\">$parameters<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$http_info<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000088;\">$twitter<\/span><span style=\"color: #339933;\">-&amp;<\/span>gt<span style=\"color: #339933;\">;<\/span>http_info<span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #000088;\">$http_code<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000088;\">$http_info<\/span><span style=\"color: #009900;\">&#91;<\/span><span style=\"color: #0000ff;\">&quot;http_code&quot;<\/span><span style=\"color: #009900;\">&#93;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<span style=\"color: #b1b100;\">if<\/span><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000088;\">$http_code<\/span> <span style=\"color: #339933;\">==<\/span> <span style=\"color: #0000ff;\">&quot;200&quot;<\/span> <span style=\"color: #339933;\">&amp;<\/span>amp<span style=\"color: #339933;\">;&amp;<\/span>amp<span style=\"color: #339933;\">;<\/span> <span style=\"color: #339933;\">!<\/span><a href=\"http:\/\/www.php.net\/empty\"><span style=\"color: #990000;\">empty<\/span><\/a><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #000088;\">$response<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n&nbsp;<span style=\"color: #b1b100;\">print<\/span> <span style=\"color: #0000ff;\">&quot;ok<span style=\"color: #000099; font-weight: bold;\">\\n<\/span>&quot;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #009900;\">&#125;<\/span> <span style=\"color: #b1b100;\">else<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\n&nbsp;<span style=\"color: #b1b100;\">print<\/span> <span style=\"color: #0000ff;\">&quot;ng<span style=\"color: #000099; font-weight: bold;\">\\n<\/span>&quot;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<span style=\"color: #009900;\">&#125;<\/span><br \/>\n&nbsp;<br \/>\n&nbsp;<a href=\"http:\/\/www.php.net\/sleep\"><span style=\"color: #990000;\">sleep<\/span><\/a><span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #cc66cc;\">3<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #666666; font-style: italic;\">\/\/ \u5ff5\u306e\u305f\u3081\u30b9\u30ea\u30fc\u30d7\u3002<\/span><br \/>\n&nbsp;<span style=\"color: #009900;\">&#125;<\/span><\/div>\n<\/div>\n<p><\/p>\n<h4>CRON\u3067\u5b9a\u671f\u7684\u306b\u5b9f\u884c<\/h4>\n<p>\u50d5\u306f\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u30e6\u30fc\u30b6\u30fc\u306a\u306e\u3060\u304c\u3001\u3055\u304f\u3089\u3067CRON\u8a2d\u5b9a\u3059\u308b\u65b9\u6cd5\u306f\u30b0\u30b0\u308b\u3068\u4e00\u676f\u51fa\u3066\u304d\u305f\u3002<br \/>\n\u3053\u3053\u304c\u53c2\u8003\u306b\u306a\u3063\u305f\u3002<a href=\"http:\/\/d.hatena.ne.jp\/Shinji_041\/20090912\/p2\" >http:\/\/d.hatena.ne.jp\/Shinji_041\/20090912\/p2<\/a><\/p>\n<p>\u4ee5\u4e0a\u3001REST\u306f\u4fbf\u5229\u3060\u30fc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#21021;&#26399;&#35373;&#23450; OAuth&#12398;&#35373;&#23450;&#12399;&#12464;&#12464;&#12427;&#12392;&#12356;&#12429;&#12356;&#12429;&#20986;&#12390;&#12367;&#12427;&#12398;&#12391;&#30465;&#30053;&#12290; http:\/\/www.google.co.jp\/search?hl=ja&amp;q=oauth+twitter+php Bot&#20316;&#25104; PHP&#12391;&#26360;&#12356;&#12390;&#12356;&#12414;&#12377;&#12290; &hellip; <a href=\"http:\/\/iida.work\/ethBlog\/?p=796\">&#32154;&#12365;&#12434;&#35501;&#12416; <span>&#29305;&#23450;&#12398;&#12461;&#12540;&#12527;&#12540;&#12489;&#12434;&#21547;&#12416;&#12484;&#12452;&#12540;&#12488;&#12434;&#12375;&#12383;&#20154;&#12434;Follow&#12377;&#12427;Twitter Bot&#12434;&#12388;&#12367;&#12387;&#12390;&#12415;&#12383;<\/span> <span>&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/1795"}],"collection":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1795"}],"version-history":[{"count":6,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/1795\/revisions"}],"predecessor-version":[{"id":4372,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/1795\/revisions\/4372"}],"wp:attachment":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}