2016-07-13 1 views
2

Я занимаюсь разработкой кода для агента по недвижимости, чтобы загрузить свойства Zoopla через их DataFeedZoopla Песочница с ошибкой заголовка HTTP Curl

У меня проблема, добавив необходимый профиль в заголовок 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 

у меня возникли проблемы при добавлении профиля в заголовок HTTP в Curl Вот мой код:

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

Ответ Я получаю от Zoopla является:

{ "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" } 

Может anbody пожалуйста посоветуйте на правильном пути, чтобы добавить профиль в заголовок?

Thanx

ответ

2

Из их примера, похоже, что вы должны передать всю строку в виде одного заголовка Content-Type 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' 
); 
+0

Thanx iainn, что сделал это: - {"status": "OK", "listings": [], "branch_reference": "test"} - урок, который вы изучили более внимательно! – bob