private function RetweetReserve($reserve)
 {
     if (is_null($reserve->tweet_id) or !strlen($reserve->tweet_id)) {
         $mes = 'ツイートIDがセットされていませんでした ReserveID: ' . $reserve->id . "\n";
         throw new Exception($mes);
     }
     //リツイート先アカウント情報取得
     $account_info = $this->getRetweetAccount($reserve->rtw_account_id);
     if (!$account_info) {
         $mes = 'リツイート先アカウント情報取得が取得できませんでした AccountID: ' . $reserve->rtw_account_id . "\n";
         throw new Exception($mes);
     }
     $twObj = new TwitterOAuth($account_info->consumer_key, $account_info->consumer_secret, $account_info->access_token, $account_info->access_token_secret);
     $retweetObj = new statuses_retweet($twObj);
     $apires = $retweetObj->setRetweetId($reserve->tweet_id)->Request();
     $apiErrorObj = new Api_Error($apires);
     if ($apiErrorObj->error) {
         $error_msg = $apiErrorObj->errorMes_Str;
         $mes = 'リツイート失敗: ' . $error_msg . "\n";
         throw new Exception($mes);
     }
     //リツイート済みフラグセット
     $this->setRetweetResult($reserve);
     $mes = 'リツイート成功 RetweetID: ' . $apires->id_str . "\n";
     error_log($mes, 3, _TWITTER_LOG_PATH . $this->logFile);
 }
Example #2
0
 public function Article_ReTweet()
 {
     if (!$this->tweet_id) {
         return false;
     }
     $retwwt_acounts = $this->getRetweetAcounts();
     if ($retwwt_acounts) {
         foreach ($retwwt_acounts as $account) {
             $twObj = new TwitterOAuth($account->consumer_key, $account->consumer_secret, $account->access_token, $account->access_token_secret);
             $retweetObj = new statuses_retweet($twObj);
             $apires = $retweetObj->setRetweetId($this->tweet_id)->Request();
             $apiErrorObj = new Api_Error($apires);
             if ($apiErrorObj->error) {
                 $mes = 'リツイート失敗 feed_id:' . $this->Article_Info->id . ' account:' . $account->account_name . ' [' . $apiErrorObj->errorMes_Str . "]\n";
                 error_log($mes, 3, _TWITTER_LOG_PATH . $this->logFile);
             } else {
                 $mes = 'リツイート成功 feed_id:' . $this->Article_Info->id . ' account:' . $account->account_name . ' retweet_id:' . $apires->id_str . "\n";
                 error_log($mes, 3, _TWITTER_LOG_PATH . $this->logFile);
             }
             unset($twObj);
         }
     }
 }
 public function Retweets($tweet)
 {
     //--getAnDuplicateTweetIDで実行
     //if(!$this->checkRetweetNum($tweet)){
     //    $mes = $tweet->id.": retweet_count: ".$tweet->retweet_count." 最低リツイート数設定に達しなかったため、リツイート未実行"."\n";
     //    error_log($mes, 3, _TWITTER_LOG_PATH.$this->logFile);
     //    return $this;
     //}
     $retweetObj = new statuses_retweet($this->twObj);
     $apires = $retweetObj->setRetweetId($tweet->id)->Request();
     //エラーチェック
     $error_msg = '';
     $success_flg = 1;
     $apiErrorObj = new Api_Error($apires);
     if ($apiErrorObj->error) {
         //エラー情報
         $error_msg = $apiErrorObj->errorMes_Str;
         $success_flg = 0;
         //ログ出力
         error_log($apiErrorObj->errorMes_Str, 3, _TWITTER_LOG_PATH . $this->logFile);
         //メッセージテーブルに書き出し
         $MTobj = new DT_Message();
         $MTobj->addMessage($apiErrorObj->errorMes_Str, (int) $this->Account_ID, 'error', 'RetweetsProcese');
     } else {
         //成功時ログ出力
         $mes = "リツイート成功 RetweetID: " . $tweet->id_str . "\n";
         error_log($mes, 3, _TWITTER_LOG_PATH . $this->logFile);
     }
     unset($apiErrorObj);
     //リツイートリストに追加 (エラー時でも追加される)
     $sql = "INSERT INTO dt_retweet_list ( account_id, tweet_id, search_str, tweet_text, retweet_success_flg, error_mes, retweet_count, create_date ) VALUES ( ?, ?, ?, ?, ?, ?, ?, now() )";
     $res = $this->DBobj->execute($sql, array((int) $this->Account_ID, $tweet->id_str, $this->SerchAction->search_str_1, $tweet->text, $success_flg, $error_msg, $tweet->retweet_count));
     return $this;
 }