I'm hoping you can help as I think I'm missing a trick here and can't find where I'm going wrong. I am looking to retrieve a few specific pieces of info from Twitter DMs via PHP. I've written some code to pull through what I'm after, but when running the script, only the message (tweet), ID, and date sent are pulling through. The rest like user name etc... remains blank. The current output can be found here: http://anonytine.hol.es/TDM94.php
Any help would be greatly appreciated:
<?php
echo "<h2>Simple Twitter API Test</h2>";
ini_set('display_errors', 1);
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "XXXX",
'oauth_access_token_secret' => "XXXX",
'consumer_key' => "XXXX",
'consumer_secret' => "XXXX"
);
$url = 'https://api.twitter.com/1.1/direct_messages.json';
$getfield = '?since_id=240136858829479935&count=20';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
echo "<h3>Direct Messages</h3>";
foreach($string as $items)
{
echo "Time and Date of Tweet: ".$items['created_at']."<br />";
echo "Message ID: ".$items['id']."<br />";
echo "Tweet: ".$items['text']."<br />";
echo "Tweeted by: ". $items['user']['name']."<br />";
echo "Screen name: ". $items['user']['screen_name']."<br />";
echo "Location: ". $items['user']['geo_enabled']."<br />";
echo "Friends: ". $items['user']['friends_count']."<br />";
echo "Listed: ". $items['user']['listed_count']."<br /><hr />";
}
{
?>