我使用paypal api来获取收款人信息。
我得到了json结果。如何获得email
,first_name
,last_name
不同的变量PHP Json格式变量声明
这里是JSON结果:
{
id: "PAY-4L2624428H450980CLD23F4A",
intent: "sale",
state: "approved",
cart: "74345738MA858411Y",
payer: {
payment_method: "paypal",
status: "VERIFIED",
payer_info: {
email: "[email protected]",
first_name: "test",
last_name: "facilitator",
payer_id: "Z2ZSX2WM9ALD2",
shipping_address: {
recipient_name: "test facilitator"
},
country_code: "SG"
}
}
}
使用谷歌,你会发现PHP函数[json_decode()](http://php.net/manual/en/function.json-decode.php)如果第二个参数设置为“true”,则转换将返回JSON作为关联数组。 –
鉴于json不是有效的json请检查[http://jsonviewer.stack.hu/] –