2012-02-24 6 views
2

누락 된 부분을 누구든지 볼 수 있습니까? 계속 응답이 없으며 xml 파일도 정확하므로 머리글과 url은 응답하지만 응답이 없습니다. 값이 될 수 있습니다 당신이 된 승인ebay api - PHP를 통해 XML 요청을 보내십시오.

$xml_response->Ack 

을 발견해야한다이 xml_response의 내부

$xml_response = simplexml_load_string($responseXML); 

을 :

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

?> 
+1

기본 디버깅이 필요합니다. Curl에는 요청에 무엇이 잘못되었는지를 알려주는 [curl_error()'] (http://php.net/curl_error) 함수가 있습니다. –

+0

감사합니다. 결국 코드를 ​​알아 냈습니다. 코드를 거의 완전히 변경했지만 작동하도록했습니다. – CKKiller

답변

0

이 시도 경고, 실패 또는 성공하고 (당신에게 오류의 유형을 제공합니다 요청에 오류가있는 경우)

관련 문제