Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过php curl发布多个参数/json值_Php_Curl - Fatal编程技术网

如何通过php curl发布多个参数/json值

如何通过php curl发布多个参数/json值,php,curl,Php,Curl,我需要一些关于php curl的帮助。 我有一个json,它在服务器上使用一个参数(leadobj)时工作正常,但在AddLead(leadobj,null)这样的多个参数下工作不正常。你能帮我分享一下如何将值传递到这种格式吗。提前谢谢 $curl_data = curl_init(); curl_setopt($curl_data, CURLOPT_URL,"https://serviceapi"); curl_setopt($curl_data, CURLOPT_POST, 1); curl

我需要一些关于php curl的帮助。 我有一个json,它在服务器上使用一个参数(leadobj)时工作正常,但在AddLead(leadobj,null)这样的多个参数下工作不正常。你能帮我分享一下如何将值传递到这种格式吗。提前谢谢

$curl_data = curl_init();
curl_setopt($curl_data, CURLOPT_URL,"https://serviceapi");
curl_setopt($curl_data, CURLOPT_POST, 1);
curl_setopt($curl_data, CURLOPT_POSTFIELDS, $json_string);
curl_setopt($curl_data, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json;'
));
curl_setopt($curl_data, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($curl_data);
curl_close ($curl_data);

看看JSON的例子也会很有帮助。所有JSON的处理方式都是一样的。只要它是有效的JSON,不管其中有多少属性,“不工作”不是一个有用的问题描述。它怎么不起作用?你预期会发生什么?会发生什么?