我在ZF2 php中使用cURL向网址发布了一个JSON数组。
使用下面的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' not supported"}
标题有问题吗? 或者JSON中的任何问题 请帮忙