About the ebay Platform Interface (PHP) Docking example

Source: Internet
Author: User
Tags findone

Get Order Interface Sample

Public Function Importebayorder () {
Set_time_limit (0);
if (Empty ($this->_shopapiebay->token)) {
Self::fail (Self::code_failure, ' Shop: '). Shop::findone ($this->_shopapiebay->id)->name. ' Empty token ');
}else {
$ps = 100;
$CP = 0;
$total _entries = 1;
$mod _time_from = date (' C ', Strtotime (' -24 hours '));
$mod _time_to = date (' C ', Time ());
$header = Array (
' Content-type:text/xml ',
' X-ebay-api-compatibility-level: '. Self::x_ebay_api_compatibility_level,
' X-ebay-api-dev-name: '. Self::x_ebay_api_dev_name,
' X-ebay-api-app-name: '. Self::x_ebay_api_app_name,
' X-ebay-api-cert-name '. Self::x_ebay_api_cert_name,
' X-ebay-api-siteid: '. 0,
' X-ebay-api-call-name:getorders ',
' X-ebay-api-request-encoding:xml '
);
$message = [];
while ($ps * $CP < $total _entries)
{
Sleep (60);
$CP + +;
$xml = ' <?xml version= ' 1.0 "encoding=" Utf-8 "?>";
$xml. = ' <getordersrequest xmlns= ' urn:ebay:apis:eBLBaseComponents ' > ';
$xml. = ' <RequesterCredentials> ';
$xml. = ' <eBayAuthToken> '. $this->_shopapiebay->token. ' </eBayAuthToken> ';
$xml. = ' </RequesterCredentials> ';
$xml. = ' <ModTimeFrom> '. $mod _time_from. ' </ModTimeFrom> ';
$xml. = ' <ModTimeTo> '. $mod _time_to. ' </ModTimeTo> ';
$xml. = ' <DetailLevel>ReturnAll</DetailLevel> ';
$xml. = ' <IncludeFinalValueFee>True</IncludeFinalValueFee> ';
$xml. = ' <OrderStatus>All</OrderStatus> ';
$xml. = ' <Pagination> ';
$xml. = ' <EntriesPerPage> '. $ps. ' </EntriesPerPage> ';
$xml. = ' <PageNumber> '. $CP. ' </PageNumber> ';
$xml. = ' </Pagination> ';
$xml. = ' </GetOrdersRequest> ';
$response = $this->_curl ($header, $xml);
if ($response->issuccess) {
Origindataebayorder::importorder ($response->data->orderarray, $this->_shopapiebay);
if (Isset ($response->data->paginationresult->totalnumberofentries)) {
$total _entries = (int) $response->data->paginationresult->totalnumberofentries;
}
}else{
$message [] = Shop::findone ($this->_shopapiebay->id)->name. ': GetOrder '. $response->message;
}
}
if (empty ($message)) {
Return self::success (self::code_success, self::code_success);
}else{
Return Self::fail (Self::code_failure, join ("\ n", $message));
}
}
}

Curl Impersonation Request
Public Function _curl ($header, $xml) {
$connection = Curl_init ();
curl_setopt ($connection, Curlopt_url, Self::ebay_ws_uri);
curl_setopt ($connection, Curlopt_ssl_verifypeer, 0);
curl_setopt ($connection, curlopt_ssl_verifyhost, 0);
curl_setopt ($connection, Curlopt_httpheader, $header);
curl_setopt ($connection, Curlopt_post, 1);
curl_setopt ($connection, Curlopt_postfields, $xml);
curl_setopt ($connection, Curlopt_returntransfer, 1);
$response = curl_exec ($connection);
Curl_close ($connection);
$response = $this->transformxmltoobject ($response);
if ($response->ack = = ' Success ') {
Return self::success ($response, self::code_success);
}else{
Return Self::fail (Self::code_failure, (string) $response->errors->longmessage);
}
}

Convert the requested XML object to an object
    Public Function Transformxmltoobject ($xml) {
Disallow referencing of external XML entities
Libxml_disable_entity_loader (TRUE);
$xmlstring = simplexml_load_string ($xml, ' simplexmlelement ', libxml_nocdata);
echo ' <pre> '; Var_dump ($xmlstring);d ie;
$val = Json_decode (Json_encode ($xmlstring), true);//goto array
return $xmlstring;
}

About the ebay Platform Interface (PHP) Docking example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.