比如这个页面的例子:
http://open.weigou.baidu.com/test/order/create_order.html
想提交下面的数据到指定的API的URL:
{
"header":{
"token":"b2a974e7bab36210bd79bde7b25d1017", //百度提供的token
"username":"jingdong", //百度账号用户名
"password":"*********" //百度账号密码
},
"body":{
"mobile":"123456", //手机号
"productId":"999" //商品编号,微购内部id
}
}
怎么做呢?
http://open.weigou.baidu.com/standard/index.html
示例第六行:curl_setopt($ch, CURLOPT_POSTFIELDS, $data ); //$data是每个接口的json字符串
。所以你只要对数组进行json_encode()
就好了。