Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change product quantity with Ebay API

Tags:

php

xml

ebay-api

I'm trying to do one simple thing. I want to change the quantity of an existing fixed priced item on ebay using PHP. Is this possible? I've asked this before and got responses telling me to read this or that. I'm not able to find any actual code examples though. I'd love to see someone post one. For example, ebay item number 123456789 has a qty of 50. I want to run some PHP code to change it to qty of 20. I want to enter the item number, the new quantity, and any ebay verification data needed into the code and run it. That's all I need.

like image 982
CheeseFlavored Avatar asked Nov 30 '14 17:11

CheeseFlavored


People also ask

What can you do with eBay API?

eBay Shopping API lets you ask eBay for information using just a URL, then get back data in XML, JSON, SOAP, or eBay's simple Name Value format. This Getting Started Guide focuses on the simplest way to use the Shopping API: using a URL as input, and getting XML back. However, you can also use SOAP and JSON.

Is API allowed on eBay?

eBay offers developers a wide range of RESTful and Traditional APIs. For new development, eBay strongly encourages the use of our RESTful APIs.

What is inventory on eBay?

Inventory Item: before a product can be sold in an offer on an eBay marketplace, an inventory item record must exist for that product. An inventory item record contains such things as product details, item condition, quantity available.


1 Answers

Try this it works for me

$feed = <<< EOD
<?xml version="1.0" encoding="utf-8"?>
<ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>$eBay->auth_token</eBayAuthToken>
</RequesterCredentials>
<Item ComplexType="ItemType">
<ItemID>$itemid</ItemID>
<Quantity> int </Quantity>
</Item>
<MessageID>1</MessageID>
<WarningLevel>High</WarningLevel>
<Version>$eBay->api_version</Version>
</ReviseItemRequest>​
EOD;

$feed = trim($feed);
        $site_id = 3;//3 For UK
        $headers = array
            (
            'X-EBAY-API-COMPATIBILITY-LEVEL: ' . $this->api_version,
            'X-EBAY-API-DEV-NAME: ' . $this->dev_id,
            'X-EBAY-API-APP-NAME: ' . $this->app_id,
            'X-EBAY-API-CERT-NAME: ' . $this->cert_id,
            'X-EBAY-API-CALL-NAME: ' . $call_name,
            'X-EBAY-API-SITEID: ' . $site_id,
        );

        // Send request to eBay and load response in $response
        $connection = curl_init();
        curl_setopt($connection, CURLOPT_URL, $this->api_endpoint);
        curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($connection, CURLOPT_POST, 1);
        curl_setopt($connection, CURLOPT_POSTFIELDS, $feed);
        curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
        $response = curl_exec($connection);
        curl_close($connection);
like image 74
Keyur Padalia Avatar answered Sep 27 '22 23:09

Keyur Padalia