?php //ライブラリの読み込み require_once("./twitteroauth/autoload.php"); use Abraham\TwitterOAuth\TwitterOAuth; //Twitterアプリの情報 $consumerKey = 'AuiQeIfPbCWeLBdSnAeFvX9f1'; $consumerSecret = 'mxifxiNM5qEfe0Iif1k8SnxINw8unf4RxxXqepQLxKOFQM2FPC'; $accessToken = '900186619738693632-ELo49lDhsGkWVAuutK5Z8X5NxqYgmU4'; $accessTokenSecret = 'jENFhTnY0Fcpn7qWWWiqrb72RVsRFpfgO1OiJeaOY9zOJ'; //接続 $connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret); //dbの取得 $db_path = "./favo.db"; $db = @unserialize(file_get_contents($db_path)); if (!$db) { $db = array();} //キーワードリスト $keyword_list = array( "#太鼓の達人", "太鼓の達人", ); //検索結果の取得 foreach ( $keyword_list as $keyword ) { $statues = $connection->get("search/tweets", array( "q" => $keyword, "count" => "100", "include_entities" => "false", "lang" => "ja", "locale" => "ja", "result_type" => "recent", )); foreach ($statues->statuses as $list) { $favo_list[] = @$list->id; } } //DBのデータの保存 file_put_contents($db_path, serialize($favo_list)); //重複の値を排除 $favo_list = array_unique($favo_list); $favo_list = array_diff($favo_list,$db); //ファボ作業 foreach ($favo_list as $value) { $statues = $connection->post("favorites/create", array( "id" => $value, "include_entities" => "false", )); }