易趣api-通过php发送xml请求

易趣api-通过php发送xml请求,php,xml,curl,ebay-api,Php,Xml,Curl,Ebay Api,有人能看到我遗漏了什么吗?我一直没有得到响应,xml文件是正确的,标题和url也是正确的,但我没有得到任何响应 <?php error_reporting(E_ALL); $URL = $_REQUEST['URL']; $site = $_REQUEST['site']; $file = fopen($URL, 'r'); $xmlRequest = fread($file, filesize($URL)); echo "<text

有人能看到我遗漏了什么吗?我一直没有得到响应,xml文件是正确的,标题和url也是正确的,但我没有得到任何响应

<?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

?>
试试这个:

$xml_response =  simplexml_load_string($responseXML);
在这个xml_响应中,您必须找到Ack

$xml_response->Ack
这些值可以是:Warning、Failure或Success,如果请求中有错误,则提供错误类型

$xml_response =  simplexml_load_string($responseXML);
在这个xml_响应中,您必须找到Ack

$xml_response->Ack

这些值可以是:Warning、Failure或Success,如果请求中有错误,则提供错误类型

这需要进行基本调试。Curl有一个函数,可以告诉你一个请求出了什么问题。谢谢,我最终找到了答案,几乎完全更改了代码,但我成功了。这需要进行基本调试。Curl有一个函数,可以告诉你一个请求出了什么问题。谢谢,我最终找到了答案,几乎完全更改了代码,但我成功了