开发者

Twitter API - How to store JSON in Array?

开发者 https://www.devze.com 2023-02-14 22:41 出处:网络
I\'m trying to get the number of followers, follows, tweets, etc. for a user. I found this api call http://api.twitter.com/1/users/show.json?screen_name=barackobama

I'm trying to get the number of followers, follows, tweets, etc. for a user.

I found this api call http://api.twitter.com/1/users/show.json?screen_name=barackobama

How do I take that json result 开发者_StackOverflow中文版and store it in an array?

Thanks


You can use json_decode and set the second parameter to true:

$json = file_get_contents("http://api.twitter.com/1/users/show.json?screen_name=barackobama");
$json_array = json_decode($json, true);

Of course for file_get_contents() to work with an URL, you have to have allow_url_fopen directive enabled in your php.ini.

0

精彩评论

暂无评论...
验证码 换一张
取 消