检索卷曲信息json_decode
问题描述:
我连接到通过电子商务应用程序的命令行中执行以下操作:检索卷曲信息json_decode
curl -u xxxxxx: https://xxxx/xxx
它返回是这样的:
{ "charge_enabled": true,
"details_submitted": true,
"email": "[email protected]",
"id": "xxxx",
"statement_descriptor": "xxxx",
"xxxx": [ "USD" ]
}
当我改变这PHP来在脚本中运行此操作,我也可以通过以下方法检索相同的信息:
$ch = curl_init('https://xxxx/xxxx');
$options = array(
CURLOPT_USERPWD=> $xxxxxx
);
curl_setopt_array($ch, $options);
$result2= curl_exec($ch);
但是,当我尝试检索电子邮件等个人信息,我无法这样做。我试着通过json_decode
这样做如下:
$parsedresult = json_decode($result2,true);
$emailretrieve = $parsedresult["email"];
此只返回一个数字1
,而不是电子邮件地址。
任何人都可以帮助并告诉我什么是错的吗?我尝试了很多已经发布在StackOverflow上的东西,但没有一个能够工作。
你能说明'$ result2'包含了什么吗? 'print_r($ parsedresult)'给你什么? – 2012-08-11 15:08:39
回声调试总是很好地工作:'var_dump($ result2,$ parsedresult,$ emailretrieve);' - 你会得到什么? – Shi 2012-08-11 15:09:59
$ result2自动打印出以下内容,不需要我回应:{“charge_enabled”:true,“details_submitted”:true,“email”:“[email protected]”,“id”:“xxxx”,“statement_descriptor” :“xxxx”,“xxxx”:[“USD”]}。 print_r($ parsedresult)返回数字1.它打印出1. – Nochbag 2012-08-11 15:13:20