我正在尝试使用zoho inventory api并将其示例curl代码转换为在php中使用。
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://inventory.zoho.com/api/v1/salesorders");
$vars = array(
"authtoken" => "",
"organization_id" => "",
"JSONString" => '{
"customer_id": 4815000000044080,
}'
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
'Authorization: Zoho-authtoken ',
'Content-Type: application/json;charset=UTF-8',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
echo $server_output;
curl_close ($ch);在页面上,我得到了这样的响应
{"code":4,"message":"Invalid value passed for JSONString"}
文档中的原始代码是
$ curl https://inventory.zoho.com/api/v1/salesorders?authtoken=ba4604e8e433g9c892e360d53463oec5&organization_id=10234695
-X POST
-H "Authorization: Zoho-authtoken ba4604e8e433g9c892e360d53463oec5"
-H "Content-Type: application/json;charset=UTF-8"
-d JSONString='{
"customer_id": 4815000000044080,
}'我尝试了各种谷歌搜索,似乎很多人都有同样的问题,但还没有给出答案。
我认为我试图以错误的方式添加JSONString
在php中使用curl发送JSONString的正确方式是什么?
发布于 2019-09-29 14:12:50
下面的代码不会给出“{”c#“:4,”message“:”“value passed for JSONString"}”错误。
https://i.stack.imgur.com/vDRRE.png
如果你有任何类型的问题,请发邮件给我。"shiva151316@gmail.com“
发布于 2020-04-30 01:42:30
我使用servise http://httpbin.org/post来查看我的post查询是如何查找zoho的。并在JSONString编码之前找到错误的符号,这是BOM编码。所以,我改变了编码,这样就可以了。
https://stackoverflow.com/questions/57879271
复制相似问题