eqpaisley Posted September 15, 2013 Share Posted September 15, 2013 Hi all. I am trying to get a list of the 3-5 most recent tweets from a feed. Using Abrahams OAuth I've been able to do it, but what I get back is a wall of information. I'm trying to figure out how to decode it and make sense of it so I can work with it (determine if a tweet is a reply or retweet, if its new, if it mentions someone specific, etc). <?php session_start(); require_once("twitteroauth.php"); //Path to twitteroauth library $twitteruser = "user_name_here"; $notweets = 10; $consumerkey = "xxxxxx"; $consumersecret = "xxxxxxx"; $accesstoken = "xxxxxxxxxx"; $accesstokensecret = "xxxxxxxxxxxxxxxxxxx"; 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($consumerkey, $consumersecret, $accesstoken, $accesstokensecret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets); echo json_encode($tweets); ?> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 16, 2013 Share Posted September 16, 2013 You could use a jquery.getJSON function, to get the content from this JSON object string and display it in readable html format. http://api.jquery.com/jQuery.getJSON/ Quote Link to comment Share on other sites More sharing options...
trq Posted September 16, 2013 Share Posted September 16, 2013 Anyone working with Rest API's needs to install postman: https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.