まず、ブラウザを起動してmetaで再読み込みなんてそれbotっていわねーよとか思った。まあ、とりあえずcronが使えるなら使えばいいと思うのですが、使えないのかな?
で、自分が本当に作ろうと思っているbotは、Twitterの場合、発言をIMで受けることができるので、そのIMのメッセージをそれこそ常駐しているbotが受けて、何か処理をする。っていう構想でした。
IMのプロトコルをしゃべれるライブラリはこれでも使えばいいかなと思っていた。
http://phpspot.org/blog/archives/2006/07/phpjabber.html
で、こっちなんだけど
PHPでTwitterのスクレイピングするクラス書いてみた
Factoryパターンで実装している意味がよくわかんないなあ。
public function __constract() { } public static function &factory ($timeline, $username = null) { $c = new Twitter_Scrape(); $c->timeline = $timeline; if ($c->timeline != TW_PUBLIC) { if ($username === null) { throw new Exception('Exception : USERNAME is required'); } } $c->username = $username; return $c; }
これじゃだめなんかな。(if文の辺りが個人的に気に食わなかったのでちょっと変えた)
public function __constract($timeline, $username = null) { if($timeline != TW_PUBLIC && is_null($username)) { throw new Exception('Exception : USERNAME is required'); } $this->timeline = $timeline; $this->username = $username; }