PHP Twitter API “GET users/lookup”. Grabbing scree

2019-06-03 16:21发布

I have made a simple Twitter API program that will loop through your Followers and grab all of them. It gets them by their IDs. How do I get their screen_name?

I know I have to do something with users/lookup with user_id as one of the parameters.

I have noticed what I think is my issue.

The JSON code that I am trying to get to goes something like this.

[
 {
  "screen_name": "twitter"
 }
]

I have done it like (below.)

{
  "screen_name": "twitter"
}

With the Lookup Function (https://dev.twitter.com/docs/api/1/get/users/lookup) it starts with the "[".

I was thinking I would have to do something like.

$LookUp_JSON->[1]->screen_name which would then print "twitter" but it's obviously not.

1条回答
相关推荐>>
2楼-- · 2019-06-03 17:02

Check out the Twitter API console ( https://dev.twitter.com/console )

.. and hack it a little bit because its undocumented from the console standpoint.

Go to users/show where you'll see this

http://api.twitter.com/1/users/show.json?screen_name={screen_name}

change it to this

http://api.twitter.com/1/users/show.json?user_id={id}

I.E for the ID of @TwitterAPI (6253282) this call

http://api.twitter.com/1/users/show.json?user_id=6253282

will get you this:

{
  "id": 6253282,
  "id_str": "6253282",
  "name": "Twitter API",
  "screen_name": "twitterapi",
  "location": "San Francisco, CA",
etc...
}
查看更多
登录 后发表回答