Can anyone see what I'm missing? I keep getting no response, The xml file is correct, so are the headers and url but I'm not getting anything in response.
<?php
error_reporting(E_ALL);
$URL = $_REQUEST['URL'];
$site = $_REQUEST['site'];
$file = fopen($URL, 'r');
$xmlRequest = fread($file, filesize($URL));
echo "<textarea>" . $xmlRequest . "</textarea>"; //this is me making sure the file
//actually contains the xml doc
$endpoint = "https://api.sandbox.ebay.com/ws/api.dll";
$session = curl_init($endpoint); // create a curl session
curl_setopt($session, CURLOPT_POST, true); // POST request type
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlRequest); // set the body of the POST
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // return values as a string - not to std out
$headers = array(
'X-EBAY-API-CALL-NAME: GetCategories',
'X-EBAY-API-SITE-ID: ' . $site,
'X-EBAY-API-DEV-NAME: *****',
'X-EBAY-API-APP-NAME: *****',
'X-EBAY-API-CERT-NAME: *****',
'X-EBAY-API-COMPATIBILITY-LEVEL: 761',
'X-EBAY-API-REQUEST-ENCODING: XML', // for a POST request, the response by default is in the same format as the request
'Content-Type: text/xml;charset=utf-8'
);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers); //set headers using the above array of headers
$responseXML = curl_exec($session); // send the request
curl_close($session);
if ($responseXML = '' OR $responseXML = ' ') {
echo "Failed!";
}
echo $responseXML;
return $responseXML; // returns a string
?>
Try this:
$xml_response = simplexml_load_string($responseXML);
Inside of this xml_response you must find Ack
$xml_response->Ack
the values can be : Warning, Failure or Success and gives you the type of error (if there was an error in the request)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.