Skip to content

Instantly share code, notes, and snippets.

@ingyesid
Created August 18, 2013 21:36
Show Gist options
  • Save ingyesid/6264127 to your computer and use it in GitHub Desktop.
Save ingyesid/6264127 to your computer and use it in GitHub Desktop.
Get user timeline , change your keys
<?
header('Content-type: application/json');
require_once('twitteroauth/twitteroauth.php');
$oauth_access_token = "YOUR_HERE";
$oauth_access_token_secret = "YOUR_HERE";
$consumer_key = "YOUR_HERE";
$consumer_secret = "YOUR_HERE";
if ($_GET["token"]!=$oauth_access_token) {
$arr = array('error' => true,'msg' => 'bad token bitch');
echo json_encode($arr);
} else {
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$_GET["username"]."&count=".$_GET["count"]);
echo json_encode($tweets);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment