{"id":734,"date":"2013-05-19T06:48:59","date_gmt":"2013-05-18T21:48:59","guid":{"rendered":"http:\/\/ts-engine.net\/?p=734"},"modified":"2013-05-19T06:48:59","modified_gmt":"2013-05-18T21:48:59","slug":"twitter-api%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e6%a4%9c%e7%b4%a2%e3%80%81%e3%83%aa%e3%83%b3%e3%82%af%e3%82%92%e3%83%91%e3%83%bc%e3%82%b9%e3%81%99%e3%82%8bperl%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97","status":"publish","type":"post","link":"http:\/\/ts-engine.net\/?p=734","title":{"rendered":"twitter API\u3092\u4f7f\u3063\u3066\u691c\u7d22\u3001\u30ea\u30f3\u30af\u3092\u30d1\u30fc\u30b9\u3059\u308bperl\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u3063\u305f\u3002"},"content":{"rendered":"<p>\n\u30a2\u30e1\u30ea\u30ab\u4eba\u306fperl\u3001python\u304c\u30e1\u30a4\u30f3\u306a\u306e\u3067\u3001\u6700\u8fd1\u306f\u3082\u3063\u3071\u3089perl\u3092\u66f8\u304f\u3053\u3068\u304c\u975e\u5e38\u306b\u591a\u3044\u3002<br \/>\n\u7279\u306b\u3001\u30a2\u30e1\u30ea\u30ab\u4eba\u306f\u65e5\u672c\u3068\u9055\u3063\u3066\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u884c\u308f\u305a\u306a\u3093\u3067\u3082\u3059\u3050\u30b9\u30af\u30ea\u30d7\u30c8\u5316\u3057\u3066\u3069\u3093\u3069\u3093\u52b9\u7387\u3042\u3052\u3066\u3044\u3053\u3046\u3068\u3044\u3046\u30de\u30a4\u30f3\u30c9\u304c\u5f37\u304f\u3042\u308b\u306e\u3067\u3001\u30a4\u30f3\u30d5\u30e9\u904b\u7528\u306e\u81ea\u5206\u3067\u3082\u3081\u3063\u3061\u3083\u30b3\u30fc\u30c9\u66f8\u3044\u3066\u3044\u308b\u3002<\/p>\n<p>\u305b\u3063\u304b\u304f\u3001perl\u306e\u30b9\u30ad\u30eb\u304c\u3064\u3044\u305f\u306e\u3067\u3001\u306a\u3093\u304bAPI\u3067\u3082\u5229\u7528\u3057\u305f\u30b5\u30a4\u30c8\u3067\u3082\u4f5c\u308d\u3046\u3068\u3068\u308a\u3042\u3048\u305a\u3001twitter\u306eAPI\u3092\u4f7f\u3063\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u307f\u305f\u3002\n<\/p>\n<p><a href=\"http:\/\/ts-engine.net\/wp-content\/uploads\/2013\/05\/the_drongo_love__happy_valentines_day_.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/ts-engine.net\/wp-content\/uploads\/2013\/05\/the_drongo_love__happy_valentines_day_-300x200.jpg\" alt=\"\" title=\"\u2665 The Drongo Love \u2665 Happy Valentine&#039;s Day \u2665\" width=\"300\" height=\"200\" class=\"aligncenter size-medium wp-image-735\" srcset=\"http:\/\/ts-engine.net\/wp-content\/uploads\/2013\/05\/the_drongo_love__happy_valentines_day_-300x200.jpg 300w, http:\/\/ts-engine.net\/wp-content\/uploads\/2013\/05\/the_drongo_love__happy_valentines_day_-768x512.jpg 768w, http:\/\/ts-engine.net\/wp-content\/uploads\/2013\/05\/the_drongo_love__happy_valentines_day_.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<!--more--><\/p>\n<h2>Net::Twitter::Lite\u3092\u5229\u7528<\/h2>\n<p>\ncpan\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001\u3042\u3068\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306e\u901a\u308a\n<\/p>\n<p>[perl]<br \/>\n#!\/usr\/bin\/perl<\/p>\n<p>use strict;<br \/>\nuse warnings;<br \/>\nuse Net::Twitter::Lite::WithAPIv1_1;<br \/>\nuse Data::Dumper;<br \/>\nuse utf8;<br \/>\nuse Encode;<\/p>\n<p>my %CONSUMER_TOKENS = (<br \/>\n    consumer_key    =&gt; &#8216;*******&#8217;,<br \/>\n    consumer_secret =&gt; &#8216;*******&#8217;,<br \/>\n);<\/p>\n<p>my $ACCESS_TOKEN        = &#8216;************&#8217;;<br \/>\nmy $ACCESS_TOKEN_SECRET = &#8216;******&#8217;;<\/p>\n<p>my $twi = Net::Twitter::Lite::WithAPIv1_1-&gt;new(%CONSUMER_TOKENS);<\/p>\n<p>$twi-&gt;access_token($ACCESS_TOKEN);<br \/>\n$twi-&gt;access_token_secret($ACCESS_TOKEN_SECRET);<\/p>\n<p>my $search_str = &#8216;\u691c\u7d22\u3057\u305f\u3044\u8a00\u8449&#8217;;<br \/>\nmy $res = $twi-&gt;search(<br \/>\n\t{<br \/>\n\t\tq =&gt; $search_str,<br \/>\n\t\tlang =&gt; &#8216;ja&#8217;,<br \/>\n\t}<br \/>\n\t);<\/p>\n<p>#\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u30c0\u30f3\u30d7\uff08\u5fc5\u8981\u3067\u3042\u308c\u3070\uff09<br \/>\n#print Dumper $res;<br \/>\n\tmy @URL;<br \/>\n\tmy $test = $res-&gt;{statuses};<br \/>\n\tforeach my $line (@$test){<br \/>\n\t\t@URL = $line-&gt;{text};<br \/>\n\t\tforeach my $url (@URL){<br \/>\n\t\t\tif ($url =~ \/(http:\\\/\\\/\\S+)(?:\\s||\\w)\/i){<br \/>\n\t\t\u3000\u3000\u3000\u3000\u3000\u3000print encode(&#8216;UTF-8&#8217;,$1.&quot;\\n&quot;);<br \/>\n\t\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\t}<br \/>\n\t\t#print encode(&#8216;UTF-8&#8217;,$url.&quot;\\n&quot;);<br \/>\n\t}<br \/>\n}<br \/>\n[\/perl]<br \/>\n\u3042\u3068\u306f\u3001\u9069\u5f53\u306b\u3001\u540d\u524d\u3092\u3064\u3051\u3066\u4ee5\u4e0b\u3092\u6253\u3066\u3070OK\u3002<br \/>\n[bash]<br \/>\npeal search.pl<br \/>\n[\/bash]<\/p>\n<p>\nhttp:\/\/**<br \/>\nhttp:\/\/**<br \/>\nhttp:\/\/**<br \/>\n\u3068\u8868\u793a\u3055\u308c\u308b\u306f\u305a\u3002<br \/>\n\u4e0a\u8a18\u306f\u30c4\u30a4\u30fc\u30c8\u3092\u691c\u7d22\u3057\u305f\u6587\u5b57\u304b\u3089\u63a2\u3057\u3066\u3001\u30c4\u30a4\u30fc\u30c8\u306bURL\u30ea\u30f3\u30af\u304c\u3042\u3063\u305f\u5834\u5408\u306b\u305d\u308c\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002<br \/>\n\u6b21\u306f\u3001Mechanize\u3067\u30ea\u30f3\u30af\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u753b\u50cf\u3092\u53d6\u5f97\u3057\u3066\u307f\u3088\u3046\u304b\u306a\u3068\u3002\n<\/p>\n<h2>\n\u305d\u306e\u4ed6<br \/>\n<\/h2>\n<p>\n\u3050\u3050\u3063\u3066\u307f\u308b\u3068\u3001API1.1\u5bfe\u5fdc\u306e\u305f\u3081\u306bpm\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u307f\u305f\u3044\u3060\u3051\u3069\u3001<br \/>\n\u81ea\u5206\u306e\u5834\u5408\u306f\u3001Net::Twitter::Lite::WithAPIv1_1\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u81ea\u5206\u306e\u3084\u308a\u305f\u3044\u3053\u3068\u306f\u554f\u984c\u306a\u304f\u8868\u793a\u3055\u308c\u305f\u306e\u3067\u3001\u3053\u308c\u3067\u3088\u3057\u3068\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a2\u30e1\u30ea\u30ab\u4eba\u306fperl\u3001python\u304c\u30e1\u30a4\u30f3\u306a\u306e\u3067\u3001\u6700\u8fd1\u306f\u3082\u3063\u3071\u3089perl\u3092\u66f8\u304f\u3053\u3068\u304c\u975e\u5e38\u306b\u591a\u3044\u3002 \u7279\u306b\u3001\u30a2\u30e1\u30ea\u30ab\u4eba\u306f\u65e5\u672c\u3068\u9055\u3063\u3066\u30de\u30cb\u30e5\u30a2\u30eb\u3067\u884c\u308f\u305a\u306a\u3093\u3067\u3082\u3059\u3050\u30b9\u30af\u30ea\u30d7\u30c8\u5316\u3057\u3066\u3069\u3093\u3069\u3093\u52b9\u7387\u3042\u3052\u3066\u3044\u3053\u3046\u3068\u3044\u3046\u30de\u30a4\u30f3\u30c9\u304c\u5f37\u304f\u3042\u308b\u306e\u3067\u3001\u30a4\u30f3\u30d5\u30e9\u904b\u7528\u306e\u81ea\u5206\u3067\u3082\u3081\u3063\u3061\u3083\u30b3\u30fc\u30c9\u66f8\u3044\u3066\u3044\u308b\u3002 \u305b\u3063\u304b\u304f\u3001perl\u306e\u30b9\u30ad\u30eb\u304c\u3064\u3044\u305f\u306e\u3067\u3001\u306a\u3093\u304bAPI\u3067\u3082\u5229\u7528\u3057\u305f\u30b5\u30a4\u30c8\u3067\u3082\u4f5c\u308d\u3046\u3068\u3068\u308a\u3042\u3048\u305a\u3001twitter\u306eAPI\u3092\u4f7f\u3063\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,6,7,18],"tags":[28],"class_list":["post-734","post","type-post","status-publish","format-standard","hentry","category-perl","category-6","category-7","category-18","tag-perl"],"_links":{"self":[{"href":"http:\/\/ts-engine.net\/index.php?rest_route=\/wp\/v2\/posts\/734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ts-engine.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ts-engine.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ts-engine.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ts-engine.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=734"}],"version-history":[{"count":0,"href":"http:\/\/ts-engine.net\/index.php?rest_route=\/wp\/v2\/posts\/734\/revisions"}],"wp:attachment":[{"href":"http:\/\/ts-engine.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ts-engine.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=734"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ts-engine.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}