Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

parsing twitter json request

$
0
0

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);
?>

Viewing all articles
Browse latest Browse all 13200

Trending Articles