Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- # https://github.com/abraham/twitteroauth
- include "lib/twitteroauth/twitteroauth/twitteroauth.php";
- # connect to twitter
- $connection = new TwitterOAuth(
- "...", #$consumer_key,
- "...", #$consumer_secret,
- "...", #$oauth_token,
- "..." # $oauth_token_secret
- );
- # get id of last retweeted by us
- # we just want to retweet newer tweets
- $response = $connection->get( 'statuses/retweeted_by_me');
- if ($response[0] )
- {
- $lastId = $response[0]->retweeted_status->id;
- }
- if (!$lastId) {
- exit();
- }
- print "Last retweeted ID: " . $lastId . "\n";
- print "Retweeting the following tweets:\n\n";
- # now get the tweets we want to retweet
- $response = $connection->get(
- 'search',
- array(
- 'q'=> '#bge OR grundeinkommen',
- 'result_type' => 'recent',
- 'rpp' => 100
- )
- );
- foreach ( array_reverse( $response->results ) as $tweet ) # reverse results, to retweet oldest first
- {
- # only retweet newer tweets
- if (
- ( $tweet->id > $lastId ) && # newer than our last RT
- ( $tweet->from_user_id != 212910781 ) && # no RT if BGEbot alread did
- ( substr($tweet->text, 0, 3 ) != 'RT ' ) && # no pure text retweets from others
- ( $tweet->iso_language_code == 'de' ) && # only tweets in German
- 1
- ){
- print $tweet->id."\t";
- print $tweet->text . "\n";
- $connection->post( 'statuses/retweet/' . $tweet->id );
- #print_r($tweet);
- }
- }
- #print_r($connection);
- print "Done.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement