通过PHP从Twitter解码JSON提要不起作用?

Ste*_*ose 3 php twitter json decode

所以我通过PHP从JSON格式下载用户的推文.我想把它解码成一个关联数组或至少一些更有用的方式,而不是一个字符串,以便我可以通过它进行操作.

我一直在疯狂阅读json_decode,但对我来说,似乎在我使用它之前和之后,文件的内容仍被检测为一个长字符串.任何人都可以帮我弄清楚我做错了什么?

$url = "http://twitter.com/status/user_timeline/" . $username . ".json?count=" . $count . "&callback=?";    

// $url becomes "http://twitter.com/status/user_timeline/steph_Rose.json?count=5&callback=?";   
        $contents = file_get_contents($url);
        $results = json_decode($contents, true);

        echo "<pre>";
        print_r($results);
        echo "</pre>";

        echo gettype($results); // this returns string
Run Code Online (Sandbox Code Playgroud)

Fel*_*ing 7

随着callback在URL中,你会得到一个字符串返回被包裹在括号( )(字符串的节选):

([{"in_reply_to_user_id":  /* ...more data here...*/ }]);
Run Code Online (Sandbox Code Playgroud)

这不是有效的JSON.

没有callback,结果只包含在[ ]哪个有效:

 [{"in_reply_to_user_id":  /* ...more data here...*/ }]
Run Code Online (Sandbox Code Playgroud)