Skip to content

Instantly share code, notes, and snippets.

@DanielHe4rt
Created Sep 15, 2021
Embed
What would you like to do?
Zup Twitter Bot
<?php
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
$tweetId = $argv[1];
$uri = 'https://twitter.com/i/api/graphql/MFRcu86F8zXkX7810z6sGA/Retweeters?variables=%7B%22tweetId%22%3A%22' . $tweetId . '%22%2C%22count%22%3A80%2C%22withTweetQuoteCount%22%3Afalse%2C%22includePromotedContent%22%3Atrue%2C%22withSuperFollowsUserFields%22%3Afalse%2C%22withUserResults%22%3Atrue%2C%22withBirdwatchPivots%22%3Afalse%2C%22withReactionsMetadata%22%3Afalse%2C%22withReactionsPerspective%22%3Afalse%2C%22withSuperFollowsTweetFields%22%3Afalse%7D';
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0';
$headers[] = 'Accept: */*';
$headers[] = 'Accept-Language: en-US,en;q=0.5';
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-Twitter-Auth-Type: OAuth2Session';
$headers[] = 'X-Twitter-Client-Language: pt';
$headers[] = 'X-Twitter-Active-User: yes';
$headers[] = 'X-Csrf-Token: x';
$headers[] = 'Sec-Fetch-Dest: empty';
$headers[] = 'Sec-Fetch-Mode: cors';
$headers[] = 'Sec-Fetch-Site: same-origin';
$headers[] = 'Authorization: Bearer seu-token-aqui';
$headers[] = 'Connection: keep-alive';
$headers[] = 'Cookie: kdt=F0B0ntiZoch7pybYmASqLf1Cml7J6hbwZRB3YJct; remember_checked_on=1; mbox=PC#d2595c5da7a5409fa68769db50cdf326.34_0#1693269092|session#dc9c3968cf2c499ea001209f0562a9e0#1630024592; cd_user_id=177ef05b78a47-00217225b507748-7f23675c-1fa400-177ef05b78b12a; auth_multi=\"1242315150591512576:ec2b7da88602b7bdd26abe94520322a1ad89b724|1098020856431824897:9b71b8e4298705e9f806b7d354bd542b66edb216\"; dnt=1; twid=u%3D1229110016; auth_token=9b72aa7bc98b6cfb79643515cee7656d711f985d; night_mode=1; des_opt_in=Y; ads_prefs=\"HBISAAA=\"; ct0=4fce0e482e3cc02a6d4a42f935b38f807b68686fac46069bbd3b1585e721e39a3ee128cc3c1e384f6616acc175b773f103b2651ce5c3a64f1a52e83a1fe706eb0d598a9447c606f45e90620d556348c8; personalization_id=\"v1_uyZAIZ3NDaGSvSgcMLs6yg==\"; guest_id=v1%3A163162458819660997; lang=pt; at_check=true';
$headers[] = 'Te: trailers';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close($ch);
$entries = json_decode($result, true)['data']['retweeters_timeline']['timeline']['instructions'][0]['entries'];
$results = [];
foreach ($entries as $entry) {
if ($entry['content']['entryType'] != 'TimelineTimelineItem') {
continue;
}
$results[] = ($entry['content']['itemContent']['user_results']['result']);
}
$names = [];
foreach($results as $result) {
$names[] = $result['legacy']['screen_name'];
}
echo "ganhador da porra toda\n";
$ganhador = rand(0, count($names) - 1);
echo "ganhou: " . ($names[$ganhador]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment