'; /* Set user access tokens. */ $access_token['oauth_token'] = 'XXXXXXXXoauth_tokenXXXXXXXX'; $access_token['oauth_token_secret'] = 'XXXXXXXXoauth_token_secretXXXXXXXX'; if ($debug > 1) { echo "

access_token

";
  print_r($access_token);
  echo "
"; } /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); /* If method is set change API call made. Test is called by default. */ $content = $connection->get('account/verify_credentials'); $c = (array)$content; if ($debug == 1) { echo "

TwitterOauth

";
  print_r($c);
  echo "
"; } // https://dev.twitter.com/rest/reference/get/statuses/user_timeline $filter = array(); $filter['screen_name'] = $screen_name; $filter['exclude_replies'] = true; $filter['include_rts'] = false; if ($last_tweet_id) { $filter['since_id'] = $last_tweet_id; // 567797801678299137; // l ast tweet id from screen name user $filter['count'] = 200; } else { $filter['count'] = 1; } // recall last 200 tweets since last_tweet_id $content = $connection->get('statuses/user_timeline', $filter); $c = (array)$content; $c = array_reverse ($c); if ($debug == 1) { echo "

Last Tweets

";
  print_r($c);
  echo "
"; } // if there is any content to post then do it foreach ($c as $key => $value) { $v = (array)$value; // the original tweet echo ($v['text'].'
'); // $tweettext = '#'.$screen_name.' '.$v['text']; $tweettext = $v['text']; // do any changes to the tweet text here: replace words, links add/remove words or links $tweettext = substr($tweettext, 0, 140); // post new Tweet here $content = $connection->post('statuses/update', array('status' => $tweettext)); // delete last id file unlink ($last_tweet_id_file); // save last_tweet_id to a file file_put_contents($last_tweet_id_file, $v['id_str']); if ($debug == 0) { echo "

New Tweet

";
    print_r($content);
    echo "
"; } } die; ?>