* */ //--------------初期設定箇所--------------// //必須 //メールアドレス $email = "メールアドレス"; //パスワード $password = "パスワード"; //オプション //content(全文出力の有無) //※有効にした場合はアクセス数が増えまので、 //mixiにアクセスブロックさる場合があります define('RSS_CONTENT',false); //自分以外の日記のRSSを生成する場合はIDを指定 //※RSSを呼び出すたびに足跡残ります $DiaryId = 0; //--------------初期設定箇所--------------// require_once('HTTP/Request.php'); //ログイン $http = new HTTP_Request("http://mixi.jp/login.pl"); $http->addHeader('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); $http->setMethod(HTTP_REQUEST_METHOD_POST); $http->addPostData("email", $email); $http->addPostData("password", $password); if($DiaryId>0){ $http->addPostData("next_url","/list_diary.pl?id=$DiaryId"); }else{ $http->addPostData("next_url","/list_diary.pl"); } if (PEAR::isError($http->sendRequest())) { exit( "Error : ".$http->getResponseCode()); } $cookie = $http->getResponseCookies(); unset($http); //check.pl if($DiaryId>0){ $http = new HTTP_Request("http://mixi.jp/check.pl?n=%2Flist_diary.pl?id=$DiaryId"); }else{ $http = new HTTP_Request("http://mixi.jp/check.pl?n=%2Flist_diary.pl"); } $http->addHeader('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); foreach ($cookie as $key){ $http->addCookie($key['name'],$key['value']); } $http->setMethod(HTTP_REQUEST_METHOD_GET); if (PEAR::isError($http->sendRequest())) { exit( "Error : ".$http->getResponseCode()); } unset($http); //list_diary.pl if($DiaryId>0){ $http = new HTTP_Request("http://mixi.jp/list_diary.pl?id=$DiaryId"); }else{ $http = new HTTP_Request("http://mixi.jp/list_diary.pl"); } $http->addHeader('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); foreach ($cookie as $key){ $http->addCookie($key['name'],$key['value']); } $http->setMethod(HTTP_REQUEST_METHOD_GET); if (PEAR::isError($http->sendRequest())) { exit( "Error : ".$http->getResponseCode()); } $ListBody = $http->getResponseBody(); $ListBody = mb_convert_encoding($ListBody,"utf8", "euc-jp"); $ListBody = preg_replace('/charset=euc-jp/', 'charset=utf-8' , $ListBody); //simplexmlにて日記箇所抽出 $ListDOM = @DOMDocument::loadHTML($ListBody); $ListXML = simplexml_import_dom($ListDOM); //タイトル取得 if($DiaryId>0){ $TitlePath = "//div[@class='diaryTitleFriend clearfix']"; }else{ $TitlePath = "//div[@class='diaryTitle clearfix']"; } foreach ($ListXML->xpath($TitlePath) as $DiaryTitle) { $DiaryTitle = $DiaryTitle->h2; } //タイトルが取得できなかった場合は終了 //(あまり頻繁にアクセスしすぎるとmixiに怒られる…) if($DiaryTitle==""){ print "データが取得出来ませんでした"; exit(); } //print $ListXML->asXML(); //exit(); print ''."\n"; if(RSS_CONTENT){ //content拡張有 print ''; }else{ //無し print ''."\n"; } print ''."\n"; print ''.$DiaryTitle.''."\n"; print 'http://mixi.jp/'."\n"; print ''.$DiaryTitle.''."\n"; print 'ja'."\n"; //日記リスト取得 $ListPath = "//div[@class='listDiaryBlock']"; foreach ($ListXML->xpath($ListPath) as $DiaryATag) { $DiaryTitle = $DiaryATag->div->dl->dt->a; $DiaryLink = "http://mixi.jp/".$DiaryATag->div->dl->dt->a['href']; $DiaryDate = $DiaryATag->div->dl->dd; //たまに改行が入ってる場合が有るので対応 $DiaryDate = ereg_replace("\r|\n","",$DiaryDate); print "\n"; //日記タイトル print "".$DiaryTitle."\n"; //日記リンク print "".htmlspecialchars($DiaryLink)."\n"; //日付 $DatePattern = "/([0-9]{4})年([0-9]{2})月([0-9]{2})日.*([0-9]{2}):([0-9]{2})/"; preg_match($DatePattern, $DiaryDate, $MatchDate); $PublishDate = date("r",strtotime($MatchDate[1].$MatchDate[2].$MatchDate[3].$MatchDate[4].$MatchDate[5])); print ""; print htmlspecialchars($DiaryATag->p); print "\n"; if(RSS_CONTENT){ //日記内容抽出 $http = new HTTP_Request($DiaryLink); $http->addHeader('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); foreach ($cookie as $key){ $http->addCookie($key['name'],$key['value']); } $http->setMethod(HTTP_REQUEST_METHOD_GET); if (PEAR::isError($http->sendRequest())) { exit( "Error : ".$http->getResponseCode()); } $DiaryBody = $http->getResponseBody(); $DiaryBody = mb_convert_encoding($DiaryBody,"utf8", "euc-jp"); $DiaryBody = preg_replace('/charset=euc-jp/', 'charset=utf-8' , $DiaryBody); $DiaryDOM = @DOMDocument::loadHTML($DiaryBody); $DiaryXML = simplexml_import_dom($DiaryDOM); // print $DiaryXML->asXML(); $DiaryPath = "//div[@id='diary_body']"; foreach ($DiaryXML->xpath($DiaryPath) as $DiaryBody) { //日記内容 print "\n"; print "asXML(); print "]]>\n"; print "\n"; } } unset($DiaryBody); unset($DiaryDOM); unset($DiaryXML); unset($http); print "$PublishDate\n"; print "\n\n"; unset($PublishDate); } print "\n"; print "\n"; exit();