Skip to content

Instantly share code, notes, and snippets.

@RonSkons
Created February 28, 2016 01:28
Show Gist options
  • Save RonSkons/02978ca7325f767350d8 to your computer and use it in GitHub Desktop.
Save RonSkons/02978ca7325f767350d8 to your computer and use it in GitHub Desktop.
A competition bot made in PHP.
<?php
require "https://raw.githubusercontent.com/J7mbo/twitter-api-php/master/TwitterAPIExchange.php";
echo "===START===<br>";
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => "");
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q=Retweet%20to%20win%20-favorite%20-follow%20-vote%20-deserves';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$data = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$json = json_decode($data, true);
$requestMethod = 'POST';
echo "===".$url."===<br>";
foreach($json['statuses'] as $item) {
$id = $item['id'];
$url = 'https://api.twitter.com/1.1/statuses/retweet/'.$id.'.json';
echo "===".$url."===<br>";
$postfields = array();
$twitter2 = new TwitterAPIExchange($settings);
$bob = $twitter2->buildOauth($url, $requestMethod)
->setPostfields($postfields)
->performRequest();
echo "===STOP===<br>";
sleep(60);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment