2016-10-27 12 views
1

私は私がeBayのPHP SDKのそれの印刷を実行すると、getOrders APIを使用することによってeBayの注文をフェッチしようとしています:。PHP eBayのGetOrdersのAPI(すべてのデータを取得できません)

「申し訳ありませんが、要求の期間内に見つかりませんエントリの変更CreateTimeFrom/CreateTimeToと私を助けてください「再び

をお試しください...

公式eBayのPHP SDKコード:私はEBAをお勧めします

<?php 
/* © 2013 eBay Inc., All Rights Reserved */ 
/* Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php */ 
?> 
<?php require_once('get-common/keys.php') ; //include keys file for auth token and other credentials ?> 
<?php require_once('get-common/eBaySession.php') ; //include session file for curl operations ?> 
<?php 
//SiteID must also be set in the Request's XML 
//SiteID = 0 (US) - UK = 3, Canada = 2, Australia = 15, .... 
//SiteID Indicates the eBay site to associate the call with 
$siteID = 0; 
//the call being made: 
$verb = 'GetOrders'; 

//Time with respect to GMT 
//by default retreive orders in last 30 minutes 
$CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()-(2*40*24*60*60)); //current time minus 80 Days 

//echo "</br>"; 
$CreateTimeTo = gmdate("Y-m-d\TH:i:s"); 


//If you want to hard code From and To timings, Follow the below format in "GMT". 
//$CreateTimeFrom = YYYY-MM-DDTHH:MM:SS; //GMT 
//$CreateTimeTo = YYYY-MM-DDTHH:MM:SS; //GMT 


///Build the request Xml string 
$requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>'; 
$requestXmlBody .= '<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">'; 
$requestXmlBody .= '<DetailLevel>ReturnAll</DetailLevel>'; 
$requestXmlBody .= "<CreateTimeFrom>".$CreateTimeFrom."</CreateTimeFrom><CreateTimeTo>".$CreateTimeTo."</CreateTimeTo>"; 
$requestXmlBody .= '<OrderRole>Seller</OrderRole><OrderStatus>All</OrderStatus>'; 
$requestXmlBody .= "<RequesterCredentials><eBayAuthToken>$userToken</eBayAuthToken></RequesterCredentials>"; 
$requestXmlBody.="<WarningLevel>High</WarningLevel>"; 
$requestXmlBody .= '</GetOrdersRequest>'; 

//Create a new eBay session with all details pulled in from included keys.php 
$session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb); 

//send the request and get response 
$responseXml = $session->sendHttpRequest($requestXmlBody); 
if (stristr($responseXml, 'HTTP 404') || $responseXml == '') 
    die('<P>Error sending request'); 

//echo "<pre>"; 
//var_dump($responseXml); 

//die; 


//Xml string is parsed and creates a DOM Document object 
$responseDoc = new DomDocument(); 
$responseDoc->loadXML($responseXml); 


//get any error nodes 
$errors = $responseDoc->getElementsByTagName('Errors'); 
$response = simplexml_import_dom($responseDoc); 
$entries = $response->PaginationResult->TotalNumberOfEntries; 

//if there are error nodes 
if ($errors->length > 0) { 
    echo '<P><B>eBay returned the following error(s):</B>'; 
    //display each error 
    //Get error code, ShortMesaage and LongMessage 
    $code = $errors->item(0)->getElementsByTagName('ErrorCode'); 
    $shortMsg = $errors->item(0)->getElementsByTagName('ShortMessage'); 
    $longMsg = $errors->item(0)->getElementsByTagName('LongMessage'); 

    //Display code and shortmessage 
    echo '<P>', $code->item(0)->nodeValue, ' : ', str_replace(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue)); 

    //if there is a long message (ie ErrorLevel=1), display it 
    if (count($longMsg) > 0) 
     echo '<BR>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue)); 
}else { //If there are no errors, continue 
    if(isset($_GET['debug'])) 
    { 
     header("Content-type: text/xml"); 
     print_r($responseXml); 
    }else 
    { //$responseXml is parsed in view.php 
     include_once 'view.php'; 
    } 
} 
?> 

答えて

1

devbay.netからY-SDK-PHP:日付については

https://github.com/davidtsadler/ebay-sdk-php

https://github.com/davidtsadler/ebay-sdk-examples

、私は間違っているかもしれないが、私はそれは日時を必要だと思います。

CreateTimeFrom = new DateTime('02-10-2016'); 
CreateTimeTo = new DateTime('02-11-2016'); 

しかし、のようなものは、私はあなたがeBay-SDK-PHPで簡単に時間を持っているだろうと思い

編集:

は、実際に私はもっと最近このいじりてきました。

$CreateTimeFrom = gmdate("Y-m-d\TH:i:s",time()-1800); //current time minus 30 minutes 
$CreateTimeTo = gmdate("Y-m-d\TH:i:s"); 

か、以下のようなあなたの範囲をハードコーディングすることができ、デフォルトの動作:次のような

//If you want to hard code From and To timings, Follow the below format in "GMT". 
//$CreateTimeFrom = YYYY-MM-DDTHH:MM:SS; //GMT 
//$CreateTimeTo = YYYY-MM-DDTHH:MM:SS; //GMT 

を:

$CreateTimeFrom = '2017-03-20T00:00:00Z'; //GMT 
$CreateTimeTo = '2017-03-22T00:00:00Z'; //GMT 

また、あなたができるだけCreatedTimeToCreatedTimeFromを使用せず、を使用してくださいの代わりに、基本的にはただCreatedTimeTo

//$requestXmlBody .= "<CreateTimeFrom>$CreateTimeFrom</CreateTimeFrom><CreateTimeTo>$CreateTimeTo</CreateTimeTo>"; 

と直下CreatedTimeFromをコメントアウトさ

それが使用NumberOfDays

$requestXmlBody .= "<NumberOfDays>2</NumberOfDays>"; 
関連する問題