Zoopla沙箱与cURL http头错误 [英] Zoopla Sandbox with cURL http header error

查看:123
本文介绍了Zoopla沙箱与cURL http头错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发房地产经纪人的代码,通过他们的datafeed上传属性到Zoopla



我有问题,需要

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

  echo'{branch_reference:test}'| 
curl --key /path/to/private.pem --cert /path/to/certificate.crt --data @ -
--headerContent-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头部
这里是我的代码:

$ $ $ $ $ $ $ $''''''''''''''''''='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)){echoCURL ERROR.curl_error($ ch)。< br>;}
$ result = curl_exec($ ch);
curl_close($ ch);

echo $ result;

我从Zoopla得到的回应是:

  {error_advice:Content-Type标题缺少'profile'参数,请提供'profile',指定您调用的方法的模式URL: sandbox / v1 / listing / list,error_name:missing_profile} 

在正确的方式添加配置文件到标题?



Thanx

解决方案

从他们的例子看来,您应该将整个字符串作为单个 Content-Type HTTP标头传递,而不是两个单独的标头:

b
$ b

  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'
);


I'm developing code for an estate agent to upload properties to Zoopla via their datafeed

I'm having problem adding a required profile to the http header that is required

The only example in the documentation is this test from 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

I'm having a problem adding the profile to the http header in cURL Here's my code:

$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;

The response I'm getting from Zoopla is:

{ "error_advice" : "The Content-Type header is missing the 'profile' parameter. Please supply 'profile', specifying the schema URL for the method you are calling: /sandbox/v1/listing/list", "error_name" : "missing_profile" } 

Can anbody please advise on the correct way to add the profile to the header?

Thanx

解决方案

From their example, it looks like you should be passing the whole string as a single Content-Type HTTP header, rather than two separate ones:

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'
);

这篇关于Zoopla沙箱与cURL http头错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆