Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.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的响应为{“error”:“Content type”application/x-www-form-urlencoded“not supported”}_Php_Json_Zend Framework_Curl - Fatal编程技术网

Php cURL的响应为{“error”:“Content type”application/x-www-form-urlencoded“not supported”}

Php cURL的响应为{“error”:“Content type”application/x-www-form-urlencoded“not supported”},php,json,zend-framework,curl,Php,Json,Zend Framework,Curl,我在ZF2 php中使用cURL将JSON数组发布到url 在下面添加带有JSON数组的代码 $data = <<< JS { "runFolder": "141015_7001367R_0388_AHANRLADXX", "sequencingMetricsProfile": "partner_run_level", "barcodeSet": "partner_barcode_set", "sequencingSamples": [ { "sequenc

我在ZF2 php中使用cURL将JSON数组发布到url

在下面添加带有JSON数组的代码

 $data = <<< JS
 {
 "runFolder": "141015_7001367R_0388_AHANRLADXX",
 "sequencingMetricsProfile": "partner_run_level",
 "barcodeSet": "partner_barcode_set",
 "sequencingSamples": [
 {
   "sequencingSampleId": "sample1",
   "lanes": [1,2],
   "barcodeSequence": "AGCTTGA",
   "targetSets": [
       "partner_cnc"
   ],
   "sequencingSampleMetricsProfile": "partner_metrics_sample_level"
 },
 {
   "sequencingSampleId": "sample2",
   "lanes": [1,2],
   "barcodeSequence": "AGCTTGT",
   "targetSets": [
       "partner_cnc"
   ],
   "sequencingSampleMetricsProfile": "partner_metrics_sample_level"
 }
 ]
}
JS;
 $adapter = new Curl();
 $client = new Client();
 $client->setAdapter($adapter);
 $client->setUri('https://api.xxxxxxxxxxxx.com/2.0/xxxx/sequencingAnalysis');
 $client->setMethod('POST');
 $adapter->setCurlOption(CURLOPT_POST, 1);
 $adapter->setCurlOption(CURLOPT_POSTFIELDS, $data);
 $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
 $adapter->setCurlOption(CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json',
  'Authorization: Bearer ' . $token
  ));
 $response = $client->send();
 print $response->getStatusCode();
 print $response->getBody();

 print_r($response);
但响应称为{error:Content type'application/x-www-form-urlencoded'notsupported}

标题有什么问题吗? 或者JSON中的任何问题
请帮助

您似乎将标题设置正确,但发送的标题错误。如果我是你,我会切换到普通卷曲,那个库的麻烦比它的价值还多。@pguardiario,你是对的。它在普通卷曲中工作