Twitterのレイアウトが変更されたようです
以前のTwitterで特定の人の発言を補足するクライアント-ソース編- - まめ畑で作った、特定の人を捕捉しまくるTwitterリーダですが、今日Twitter本家のレイアウトが華麗に変更されていたので動かなくなってしまいました。
なので、ソースを一部変更しました。
変更があるのは、OreOreTwitter.phpです
<?php require_once 'HTTP/Request.php'; define("USER_TIMELINE","http://twitter.com/"); class OreOreTwitter{ protected $userId; protected $password; protected $screenName = ""; public function OreOreTwitter($userId = "", $password = ""){ $this->userId = $userId; $this->password = $password; } public function setScreenName($screenName){ $this->screenName = $screenName; } public function getResDom($page = 1){ if($this->screenName == ""){ throw new Exception("Screen Name is NOT SET"); } $request = new HTTP_Request(USER_TIMELINE . $this->screenName . "?page=" . $page); $respons = $request->sendRequest(); if(PEAR::isError($respons)){ throw new Exception("Timeline get ERROR"); } $dom = @DOMDocument::loadHTML($request->getResponseBody()); return $dom; } public function getUserImage($body){ $xml = simplexml_import_dom($body); $image = $xml->xpath("//h2[@class=\"thumb\"]"); return (string)$image[0]->a[0]->img[0]["src"]; } public function getFriendTimeLine($body, $page){ $xml = simplexml_import_dom($body); $contents = array(); $i = 0; //変更箇所 $entry_array = $xml->xpath("//div[@class=\"status-body\"]"); foreach($entry_array as $entry){ $time = $this->getJpTime((string)$entry->span[1]->a[0]->span[0]["title"]); $content = strip_tags($entry->span[0]->asXML()); $contents[$i++] = array("message"=>$content, "date"=>$time); } return $contents; } protected function getJpTime($originTime){ return date("Y/m/d H:i:s", strtotime($originTime)); } } ?>
今までは、ユーザTLの1ページ目の最新の発言のところだけ構造が違っていたのですが、新しいデザインでは全ページ同じ構造になっているようです。
後は、TLのタグのClassに発言したユーザのIDがセットされているのでごにゅごにゅしやすくなりました。
このプログラム拡張用のメソッドとか実は作ってあったようで機能拡張し忘れてましたorz
作らないと。