提取curl请求的元素

时间:2013-06-07 22:44:34

标签: php instagram

我有一些卷曲代码,当我运行它并回显$ httpResponse = curl_exec($ ch)时,会打印以下内容。我将如何从中单独提取元素?

httpresponse{"access_token":"233408318.617bf98.6adcf10f06d04f8ca7d66ccb61a829ba","user":{"username":"jsniff","bio":"","website":"","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/anonymousUser.jpg","full_name":"","id":"233408318"}}   

1 个答案:

答案 0 :(得分:1)

如果您解析json_decode领导"httpresponse"

{将完成工作

尝试:

print_r(json_decode(substr($httpResponse,12)));

您可以访问对象:

$responseObj=json_decode(substr($httpResponse,12));
echo $responseObj->user->username;