Skip to content

Instantly share code, notes, and snippets.

@ahmadsopian311
Created July 5, 2015 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadsopian311/0c38f6f5e4281bad6f72 to your computer and use it in GitHub Desktop.
Save ahmadsopian311/0c38f6f5e4281bad6f72 to your computer and use it in GitHub Desktop.
get 3200 tweet timeline
<?php
include_once('twitteroauth/twitteroauth.php');
$connection = new TwitterOAuth('UVQqJNvAQcPeYFHlK9ZaQ', 'BFbqNPAVSjWxV5MXp3qMDbOO6EC6wGpbZaDr6LazVM', '364083466-pzcGEPvR1uFAODYVOh7KcpEL1AWGhB3G109YISDX', 'py3brnYgb7u7QbHVXEy8lyw60Fbzy9gjzZHiVIRiDKMfc');
$content = $connection->get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=@infopinang&count=200&include_rts=1');
$i=1;
// get first batch of tweets from api
$j = 0;
foreach ($content as $tweet) {
echo '<tr><td>'.$j.'</td><td>'.$tweet->text. '<td/></tr>';
$tweet_text = mysql_real_escape_string($tweet->text);
mysql_query("INSERT INTO data_mentah (tweet_text) VALUES ('$tweet_text')");
$j++;
}
$x = 0;
while ($x < 15) {
$text = array();
foreach ($content as $tweet) {
$text[] = $tweet->id_str;
echo '<tr><td>'.$j.'</td><td>'.$tweet->text. '<td/></tr>';
$tweet_text = mysql_real_escape_string($tweet->text);
mysql_query("INSERT INTO data_mentah (tweet_text) VALUES ('$tweet_text')");
$j++;
}
$last_tweet = end($text);
$content = $connection->get('statuses/user_timeline', array(
'count' => 200, 'screen_name' => '@infopinang', 'include_rts' => 1, 'max_id' => $last_tweet
));
foreach ($content as $tweet) {
echo '<tr><td>'.$j.'</td><td>'.$tweet->text. '<td/></tr>';
$tweet_text = mysql_real_escape_string($tweet->text);
mysql_query("INSERT INTO data_mentah (tweet_text) VALUES ('$tweet_text')");
$j++;
}
$x++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment