Reputation: 143
I'm wondering if I can show the latest Tweet of multiple Twitter users specified by me.
This is what I have with the keys removed, they are indeed defined in my actual code:
<?php
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?user_id=McDonalds,Wendys,Dominos&count=1';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();
echo '<pre>';
$response = var_dump(json_decode($response));
But it only outputs my latest Tweet. How can I make it so it outputs the latest Tweet of the specified users?
Upvotes: 4
Views: 982
Reputation: 14334
There are two ways to do this - neither is quite as simple as you want.
Firstly, you could request the user timeline for each user individually.
So call https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=McDonalds
and then https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=Wendys
and so on.
That might be slow. So, alternatively, you could create a list with all the users you want to follow.
Then you can use the List API to get all the recent tweets of those users.
Upvotes: 3