本文介绍了PHP Twitter的API"获得用户/查找&QUOT ;.从ID SCREEN_NAME拼抢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个简单的Twitter的API程序,将遍历您的关注,并抓住他们。它通过其ID得到他们。我如何得到他们的SCREEN_NAME?

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?

我知道我必须做一些用户/查找与USER_ID作为参数之一。

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.

这是我想获得的JSON code到是这样的。

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
那么这将打印叽叽喳喳,但它显然不是。

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

推荐答案

查看Twitter的API控制台()

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

..并攻击它一点点,因为它从控制台的角度来看无证。

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

用户/节目在那里你会看到这个

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

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

改成这样

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

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

即对@TwitterAPI的ID(6253282)此调用

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

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

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

会得到你这样的:

{
  "id": 6253282,
  "id_str": "6253282",
  "name": "Twitter API",
  "screen_name": "twitterapi",
  "location": "San Francisco, CA",
etc...
}

这篇关于PHP Twitter的API"获得用户/查找&QUOT ;.从ID SCREEN_NAME拼抢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:16