Jump to content

parsing twitter json request


eqpaisley

Recommended Posts

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);
?>
Link to comment
https://forums.phpfreaks.com/topic/282174-parsing-twitter-json-request/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.