0

I'm trying to list tweets from multiple users. I have the usernames in an array, and all was working fine with the 1.0 Twitter API, i was using something like

http://search.twitter.com/search.json?q=from%3username1+OR+from%3username2

Now i tried with the new 1.1 query string and nothing is working.

eg

https://api.twitter.com/1.1/search/tweets.json?q=from%3username

suggestions?

Jimbo
  • 25,790
  • 15
  • 86
  • 131
Simone
  • 25
  • 1
  • 8

1 Answers1

4

Yeah, you can't just change the string and that's it ;)

You need to make authenticated requests (OAuth).

This post will walk you through exactly how to make authenticated requests to the 1.1 API using Oauth.

This post, although a little more complex because it involves multiple users and also multiple hashtags, shows how you can join multiple users in a query (although it looks like you've already got that covered).

You've got the gist of the actual query you need to make, so well done for doing some research and reading the docs. However, performing 1.1 requests is a little more involved now.

Community
  • 1
  • 1
Jimbo
  • 25,790
  • 15
  • 86
  • 131
  • thank you, ive read that post before and succesfully achieved to list...one user! :( i think because it is a timeline....so I obviuosly changed the queru to the GET search but it doesnt work and if i try to add more than one user in the timeline query, i have errors, i think because the user timeline query wont allow multiple users. – Simone Jun 14 '13 at 18:44
  • the error i got is "Could not authenticate you","code":32" but i know my token/keys are correct because if I use the user timeline query, i have that correctly working update: HOLD ON it seems to be working now :) i will make some tests and i'll update this message once again, for now thanks, im using your library and it's great. – Simone Jun 14 '13 at 18:53
  • adding a third user, it just show only two, for example with this `$url = 'https://api.twitter.com/1.1/search/tweets.json'; $requestMethod = 'GET'; $getfield = '?q=from:twitter+OR+from:twitterapi+OR+from:techcrunch'; $twitter = new TwitterAPIExchange($settings); $json = $twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); var_dump(json_decode($json));` – Simone Jun 14 '13 at 19:17
  • According to twitter there may always be sligh discrepancies between what's on the twitter site and the data retrieved from the API. Nonetheless I'll take a look. – Jimbo Jun 14 '13 at 19:56
  • Sure but if I pick them singularly, data for those particular users is working fine – Simone Jun 15 '13 at 08:39
  • I think I've figured why... the user with more recents tweeets "fills" the 15 results that the query output so the other users with tweets that are older than the 1st one (in this case techrunch) are hidden. so the questions comes natural: how do i pick only the first (and recent) tweet from an user? I've tried count=1 but it just output the first overall tweet (it was nicer if it gave 1 tweet for each user :P ) – Simone Jun 15 '13 at 13:52
  • @Simone Unfortunately this is beyond the scope of the question - I'm not exactly sure how you would perform such complex queries. Maybe worth another question :) – Jimbo Jun 17 '13 at 12:27