skip to Main Content

Everybody.

Have a question about ebay trading api.

I’m trying to get all orders for authorized user.
I’m developing my web application using PHP.

So, I use this sdk:
https://github.com/davidtsadler/ebay-sdk-php

I’m getting list using getOrders method:

http://developer.ebay.com/devzone/xml/docs/Reference/ebay/GetOrders.html

Here is my code example:

public function getOrders(){
        $service = $this->getTradingService();

        $args = array(
            //"OrderStatus"   => "Completed",
            "OrderStatus"   => "All",
            "SortingOrder"  => "Ascending",
            "OrderRole"     => "Seller",

            //"CreateTimeFrom"   => new DateTime('2015-01-01'),
            "CreateTimeFrom"   => new DateTime('2000-01-01'),
            "CreateTimeTo"   => new DateTime(),
        );

        $request = new TypesGetOrdersRequestType($args);
        $request->RequesterCredentials = new TypesCustomSecurityHeaderType();
        $request->RequesterCredentials->eBayAuthToken = $this->userToken;
        $request->IncludeFinalValueFee = true;
        $request->Pagination = new TypesPaginationType();
        $request->Pagination->EntriesPerPage = 100;
        $pageNum = 1;

        $orders = [];

        do {
            $request->Pagination->PageNumber = $pageNum;

            $response = $service->getOrders($request);

            if (isset($response->Errors)) {

                $message = '';

                foreach ($response->Errors as $error) {
                    $message .= $error->ShortMessage;
                }

                throw new Exception($message);
            }

            if ($response->Ack !== 'Failure' && isset($response->OrderArray)) {
                foreach ($response->OrderArray->Order as $order) {
                    $orders[] = $order->toArray();
                }
            }

            $pageNum += 1;
        }
        while(isset($response->OrderArray) && $pageNum <= $response->PaginationResult->TotalNumberOfPages);

        return $orders;
}

It works fine for me except one issue.
I can’t get buyer email.

$orders[0]['ShippingAddress']['ExternalAddressID'] 

Is empty.

$orders[0]['TransactionArray']['Transaction'][0]['Buyer']['Email']

Is string value “Invalid Request”

If somebody knows way to get buyers emails.

Or just get informatioan about many users in one request(so I could simply merge them).

UPDATE:

Also tried to do the same without SDK.

public function getOrders2(){
        $xml = '<?xml version="1.0" encoding="utf-8"?>
                <GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">
                  <CreateTimeFrom>2000-01-01T00:00:00</CreateTimeFrom>
                  <CreateTimeTo>2015-10-22T00:00:00</CreateTimeTo>
                  <IncludeFinalValueFee>true</IncludeFinalValueFee>
                  <OrderRole>Seller</OrderRole>
                  <OrderStatus>All</OrderStatus>
                  <DetailLevel>ReturnAll</DetailLevel>
                  <RequesterCredentials>
                    <eBayAuthToken>' . $this->userToken . '</eBayAuthToken>
                  </RequesterCredentials>
                </GetOrdersRequest>';

        $url = 'https://api.ebay.com/ws/api.dll';
        $results = $this->sendPostRequest($xml,$url);
        $results = new SimpleXMLElement($results);
        return $results;
    }

Get the same issue.

Thanks

3

Answers


  1. Need change SiteID to id User Registration.

    $config = [
                'apiVersion' => ServicesTradingService::API_VERSION,
                'siteId' => ConstantsSiteIds::US, 
                'credentials' => [
                    'appId'  => getenv('EBAY_APP_ID'),
                    'certId' => getenv('EBAY_CERT_ID'),
                    'devId'  => getenv('EBAY_DEV_ID')
                ],
                'sandbox' => false
            ];
    
    Login or Signup to reply.
  2. If the order is too old then it will will result in Invalid Request ( Simply saying ” This orders is XX days old and we wont provide email address for it )

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search