【发布时间】:2016-04-25 04:53:01
【问题描述】:
我已经集成了Wepay payment gateway。但是我在通过json object to wepay 时遇到了问题。它总是显示不正确的 json 格式。请看下面的代码。
$forca_a = array(
'debit_opt_in'=>true
);
$forca = json_encode($forca_a,JSON_FORCE_OBJECT);
$wepay_create_array = array(
'name' =>"xxxx",
'description' => "xxxxxxxxx xxxx",
'callback_uri' => "xxxxxxx",
'country' => "CA",
'currencies' => array('CAD'),
'country_options' => $forca,
'rbits'=> array(
array(
'receive_time'=>strtotime("now"),
'type' =>'website_uri',
'source' => 'partner_database',
'properties'=> array('uri'=>xxxxx)
)
)
);
如果我不传递country_options,它似乎可以工作,但如果我传递这个参数,它总是给我一个错误,说“JSON 格式不正确”。
我向wepay帮助中心发送了一封电子邮件。他们告诉我,您传递的是字符串"country_options":"{"debit_opt_in":true}" <--- this is a string 而不是"country_options":{"debit_opt_in":true} <--- this is a JSON object。所以我很困惑。我不知道如何传递 JSON 对象。唯一的办法是json_encode($object)。
【问题讨论】: