【问题标题】:Twitter API - How to store JSON in Array?Twitter API - 如何将 JSON 存储在数组中?
【发布时间】:2011-03-06 15:48:59
【问题描述】:

我正在尝试获取用户的关注者、关注、推文等数量。

我发现这个api调用http://api.twitter.com/1/users/show.json?screen_name=barackobama

如何获取该 json 结果并将其存储在数组中?

谢谢

【问题讨论】:

    标签: php twitter


    【解决方案1】:

    可以使用json_decode,将第二个参数设置为true:

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

    当然,要让 file_get_contents() 使用 URL,您必须在 php.ini 中启用 allow_url_fopen 指令。

    【讨论】:

    • 谢谢。正是我需要的。
    猜你喜欢
    • 1970-01-01
    • 2020-04-13
    • 1970-01-01
    • 1970-01-01
    • 2018-02-15
    • 1970-01-01
    • 1970-01-01
    • 2014-06-26
    • 1970-01-01
    相关资源
    最近更新 更多