Php Zoopla沙盒带有cURL http头错误

Php Zoopla沙盒带有cURL http头错误,php,http,curl,header,Php,Http,Curl,Header,我正在为一家房地产代理开发代码,通过他们的数据源将房产上传到Zoopla 将所需配置文件添加到所需的http标头时遇到问题 文档中唯一的示例是来自linux的此测试: echo '{ "branch_reference" : "test" }' | curl --key /path/to/private.pem --cert /path/to/certificate.crt --data @- --header "Content-type: application/json; profile=h

我正在为一家房地产代理开发代码,通过他们的数据源将房产上传到Zoopla

将所需配置文件添加到所需的http标头时遇到问题

文档中唯一的示例是来自linux的此测试:

echo '{ "branch_reference" : "test" }' |
curl --key /path/to/private.pem --cert /path/to/certificate.crt --data @-
--header "Content-type: application/json;
profile=http://realtime-listings.webservices.zpg.co.uk/docs/v1.1/schemas/listing/list.json"
https://realtime-listings-api.webservices.zpg.co.uk/sandbox/v1/listing/list
在cURL中将概要文件添加到http头时遇到问题 这是我的密码:

$json['branch_reference']="test";
$json=json_encode($json);

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSLKEY,'private.pem');
curl_setopt($ch, CURLOPT_SSLCERT,'zpg_realtime_listings_1468337696150754_20160712-20260710.crt');
curl_setopt($ch, CURLOPT_URL, "https://realtime-listings-api.webservices.zpg.co.uk/sandbox/v1/listing/list");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json', 
  'profile: http://realtime-listings.webservices.zpg.co.uk/docs/v1.1/schemas/listing/list.json'
  ));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
if(curl_error($ch)){echo "CURL ERROR ".curl_error($ch)."<br>";}
$result = curl_exec($ch);
curl_close($ch);

echo $result;
anbody能否建议将配置文件添加到标题的正确方法


Thanx

从他们的示例中,看起来您应该将整个字符串作为一个
内容类型
HTTP头传递,而不是两个单独的头:

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json; profile=http://realtime-listings.webservices.zpg.co.uk/docs/v1.1/schemas/listing/list.json'
);

Thanx iainn,就是这样:-{“状态”:“确定”,“列表”:[],“分支参考”:“测试”}-从更仔细的观察中学到的一课!
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json; profile=http://realtime-listings.webservices.zpg.co.uk/docs/v1.1/schemas/listing/list.json'
);