phpã§botä½ããªãcurlãããã¨æã
å æ¥ã®邪気眼botã®è©±ãphpã§botä½ãã®ã«ããã¤ãæ¹æ³ãããã®ã§ãããä»åcurlã使ãã¾ããã
åèã«ããã®ã¯
ãã¨ããã²ã¨ã¤å¿ãã¡ãã£ãããã¿ã¾ããã
éªæ°ç¼botã¯ãªãã©ã¤ã¨ã©ã³ãã çºè¨é¨åãå¥ã¹ã¯ãªããã«ãã¾ããã
ä»åã¯ã©ã³ãã é¨åè¦ã¦ããã¾ãããã ã®ã©ã³ãã ããç°¡åãããã®ã§å¤é¨ããæ
å ±ãåãè¾¼ãã§ã¾ãã
ãããä»twitterã®rssããã¨ã£ãã®ã§ãèªã¿è¾¼ã¿ãpostã両æ¹ã®ãµã³ãã«ã«ãªããã¨æãã¾ããï¼ã»ã¨ãã©ä»æããã®ã³ããã ãã©NEï¼
ã½ã¼ã¹ï¼ä¸é¨ï¼
<?php $username = "ãªã¾ã"; $password = "ãã¹ã¯ã¼ã"; //buzztterã®rssãåå¾ $host = "http://twitter.com/statuses/user_timeline/5567702.rss"; //以ä¸ã¯ZAPAããã¨ããã¨åãæã ////cURLã»ãã·ã§ã³ãåæåãã $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); //////cURLã»ãã·ã§ã³ãå®è¡ãã $result = curl_exec($ch); //// //////cURLãªã½ã¼ã¹ãéããã·ã¹ãã ãªã½ã¼ã¹ã解æ¾ãã curl_close($ch); //XMLæååããªãã¸ã§ã¯ãã«ä»£å ¥ãã $XML = simplexml_load_string($result); //å¾ãããxmlãã¼ã¿ããã«ããã«ã //buzzterã®çºè¨ã¯ã«ã³ãã§åºåãããåèªãªã®ã§ããããã©ã³ãã ã«æ½åºã //ãããã¾ãã©ã³ãã ãªãã³ãã¬ã«å½ã¦ã¯ããäºããã£ã¦ã¾ã //ãã¹ãé¨å //ãã¹ãã¯é¢æ°ã使ãã¾ã tweet($massage ,$username,$password); function tweet($massage ,$username,$password) { $massage =urlencode($massage); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://twitter.com/statuses/update.xml'); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "status=$massage "); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); $buffer = curl_exec($ch); curl_close($ch); } ?>
ã¡ãã»ã¼ã¸çæé¨åã¯å²æãã¾ããã
phpã§twitteré¢é£ã®äºããããã¨ããã¨ãæ
å ±ãããããã§ããã¾ããªãã£ãããã¾ãã
pearãã©ã¤ãã©ãªã¯æ¥µå使ããããªãï¼èªåã§ã¤ã³ã¹ãã¼ã«ã§ããªãâ¦ï¼ã®ã§ãã»ã¼æ¨æºã§ããcUrlã®ããæ¹ã¯ãããããã£ãã§ãã
ãªãã©ã¤ã¯ããªãã¢ãã£ã½ãæ¹æ³ã§å®è£
ãã¦ãã¾ããããããæéã®ããæã«ã
ãã¨ã¯ãã©ãã¼è¿ãã§ããããããé å¼µãã
botã¯ã¢ã¤ãã¢æ¬¡ç¬¬ã§è²ã
åºæ¥ããã ããæ·å±
ãä½ãããªã®ã§çããç·´ç¿ãã¦ãä½ã£ã¦ã¿ã¦ã¯ãããã§ããããã
以ä¸åèã«ãªããããªãµã¤ãï¼è¨èªã¨ããã©ãã©ã§ãï¼
八角研究所 : 誰でも簡単にできる Twitter ボット作成入門
式波botを作る - 看招 血染東方一片紅
http://d.hatena.ne.jp/tek_koc/20080804/1217822667