Ebay PHP API
Aus XT Knowledge Base
<? class EbayItemInfo { public $title; public $link; public $bids; public $price; public $timeleft; function __construct( $xml ) { if( $xml === false ) { $this->title = "Invalid Request"; $this->link = "http://ebay.de"; return; } if( $xml->Ack != "Success" ) { $this->title = $xml->Errors->ShortMessage; $this->link = "http://ebay.de"; return; } $this->title = $xml->Item->Title; $this->link = $xml->Item->ViewItemURLForNaturalSearch; $this->bids = $xml->Item->BidCount; $this->price = sprintf( "%.2f €", $xml->Item->ConvertedCurrentPrice ); $this->timeleft = $xml->Item->TimeLeft; } } class EbayRequest { private $_appid; private $_ebayurl; function __construct( $appid, $ebayurl ) { $this->_appid = $appid; $this->_ebayurl = $ebayurl; } function createParamList( $data ) { $req = ""; foreach( $data as $key => $value ) $req .= $key . '=' . $value . '&'; return substr( $req, 0, strlen($req)-1 ); } function getItemInfo( $itemid ) { $data = array( 'callname' => 'GetSingleItem', 'responseencoding' => 'XML', 'appid' => $this->_appid, 'siteid' => 77, 'version' => 515, 'ItemID' => $itemid ); $params = $this->createParamList( $data ); $url = $this->_ebayurl.'?'.$params; $file = file_get_contents( $url ); if( $file === false ) return false; $xml = new SimpleXMLElement( $file ); return new EbayItemInfo( $xml ); } }; /* $ebay = new EbayRequest( $_CFG['EBAY_APPID'], $_CFG['EBAY_URL'] ); $result = $ebay->getItemInfo( '320572036895' ); print_r( $result ); */ ?>