Monday, November 16, 2009

Amazon Seller Central API Integration with Shopping Cart

We had a task with a German client Integrate her online shop with Amazon API so she can update inventory of her two websites on Amazon through Amazon API, which took three days with sleepless nights but at last we succeeded Integrating OSCommerce & XTCommerce shopping carts with Amazon Seller Central API. It took a lot of our time in reading development API manuals, forums and articles on internet but of no use. Most of the people were found complaining of insufficient help material and non-availability of example source code in many development languages in practice today.

Each step moving forward working on it, you will find a new way of doing it and you will simply be revolving around in the dark amazon. Sending request to amazon through SOAP attachment having xml data of all the products to be updated, or using the API URLs to send flat file attachment to. You will just mess up everything.

First of all, I would like to share my experience with SOAP attachments with Action for amazon defined in XML as _POST_INVENTORY_AVAILABILITY_DATA_ (and others using Posting Data guidlines)

$messageType = '_POST_INVENTORY_AVAILABILITY_DATA_';
$document = 'http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">1.01' . $merchantid . '
Inventory';
//loop through quantity
$document .='
1
Update
10009334
25
';
$document .='';

Then submit the above Document string to thie following function which will send it to appropriate amazon url:

postDocument($messageType, $document)

function postDocument($messageType, $document) {
$this->error = null;
// create the attachment to add to the SOAP call
$attachment = new SOAP_Attachment('doc', 'application/binary', null, $document);
$attachment->options['attachment']['encoding'] = '8bit';
$params = array('merchant' => $this->merchant,
'messageType' => $messageType,
'doc' => $attachment);
$options = array('trace' => true, 'timeout' => '10', 'attachments' => 'Mime');
$result = $this->client->call('postDocument', $params, $options);
if(PEAR::isError($result)) {
echo $this->error = "Error: " . $result->getMessage();
return false;
}
return $result;
}

And what you get at last is an error in all the ways you do it:
Error: Unable to retrieve WSDL https://merchant-api.amazon.de/gateway/merchant-interface-mime,

If you access this url directly, It will prompt for seller central user id and password but it complained that wsdl cannot be found even I tried saving this wsdl to local directory …
Then on the second attempt we tried Amazon AIM Document and used URL based amazon functions which works with tab delimited file formats. At first, we tried sending the simplest Price/Quantity Update flat file through CURL as attachment and spends whole day find solution to this particular error:

Feed Processing Summary:
Number of records processed 0
Number of records successful 0
original-record-number sku error-code error-type error-message
0 6000 Error Column "sku" is missing and is required.
0 6000 Warning The following columns are not recognized and will be ignored:

WoAH !!! SKU is present in the file and it is still complaining its missing? Oh man!!! Curl is not sending the flt file as attachment. After realizing this we login to the seller central account and uploaded the same file for Price/Quantity Updated … Oh Its Working.

Finally!

$user = '';
$pass = '';
$id = ''; // Merchant ID
$name = ''; // Merchant store name
$authentication = base64_encode($user . ":" . $pass);
$itemsFeedURL = "https://secure.amazon.de/exec/panama/seller-admin/catalog-upload/add-modify-delete";
// TAKE BATCH FILE PATH WHICH INCLUDE RECORDS TO BE UPDATED
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$file = $root."PriceInventory.txt";
$authentication = base64_encode($user . ":" . $pass);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $itemsFeedURL);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $file);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($file_string));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . $authentication ,
'Content-Type: text/xml;charset=UTF-8',
'BatchID: Y'
));
echo $result = curl_exec($ch);
curl_close($ch);

So you can populate your products quantity/Price against their SKU from any shopping cart DB in an inventory batch file template (get it from your Seller Central Account Products Update Area), attach it wil Curl Request and submit to amazon API.

The API do not promise to do it for you instantly, so you have to wait for a few minutes to see the results of this batch file. I have mentioned ‘BatchID:Y’ in Curl header request, which means API will return your BatchID being processed, you can view status of this BatchID in a separate request or you can login Seller Central Account to see the result of Your file Batches being processed.


Wednesday, November 11, 2009

Consuming Amazon API Web Services to enhance your website

Now everybody heard of Amazon.com. What not everybody knows that Amazon released an API to access its huge catalogs. What this basically means is that each developer can access the information from Amazon following some simple protocols and every site owner can enhance his own website with content and features from Amazon.

The Amazon API comes as a simple Webservice. Here are the first Web services that they have exposed:
  • Product Display : The ability to search for and retrieve product information from the Amazon.com catalog.
  • Shopping Cart : The ability to add Amazon.com products to shopping carts, wish lists, and registries from third party locations.

No matter of your intentions, you will first need to register and obtain a valid developer token. You can get your token here at this address: http://www.amazon.com/webservices

The current listed implementation of Amazon webservices uses Keyword searches. It has basically the same results as searching the books catalog online. As any developer/webmaster can see in the "Amazon.com Web Services Developers Kit v 1.0" document, a lot of other Amazon features are exposed. This would imply extending the base structure I present here.

There are multiple approaches from a developer's point of view. The simplest one deals with SOAP and web services classes already implemented in PHP. You could also extend the PEAR's XMLParser object to parse Amazon results. The reason I did not choose these directions is because they require additional extensions installed with PHP. What I currently use is the XML parsing package that comes embedded in PHP, so it is slightly more general.

What basically happens in this implementation is that the search word entered by the used is embedded into a XML url that is then retrieved from Amazon.com. Then PHP builds a nice display for the information received.

A class collection in the extensive package provided by Manuel Lemos:
http://www.phpclasses.org/browse.html/package/642.html

Friday, October 23, 2009

Intel Developers Program - Software N...

Intel Developers Program - Software Network

As a follow up to the Intel® Black Belt Software Developer title, Intel is introducing a new ranking system on Intel Software Network Communities.
Intel® Brown Belt Software Developer and Intel® Green Belt Software Developer are the new titles to recognize members who participate actively, share knowledge & contribute to our communities.

Which 'belt' are you? Find out for yourself. All you need to do is accept the Terms and Conditions below to enroll into the Intel® Black Belt Software Developer Program and ranking system. Then, click on your user profile. Your profile will show all contributions and points accumulated for the past 12 months as well your current status.

Intel® Black Belt Software Developer Rules

  1. A member is eligible to participate in the Intel® Black Belt Software Developer program if he/she has registered with the Intel® Software Network at www.intel.com/software.

  2. Intel will set up a contribution account to record points earned by each member for contributions made. A member can earn points by contributing to the developer communities of Intel Software Network. We may refuse to award points for a contribution for any good reason. To record points the member needs to login to the Intel Software Network website.

  3. You will earn points based on the contributions you make to the Intel Software Network communities via content submissions to forums posts, blogs, articles, code samples, contest entries etc during a membership year.

  4. Points will be accumulated for every type of submitted content (forum comments, posts, blog comments, articles and contest entries) as follows:

    1. Forum post / Content comments: 10 points
    2. Forum answer/ Contest entry: 20 points
    3. Online Testimonials (Applicable only to the Academic Community): 20 points
    4. Video submission: 40 points
    5. Coding contest entry/ Article/ White Paper/ Code Sample submission/ Blog post: 80 points

      In addition, you can accumulate points as follows:
    6. Discussion Forums: If you choose a best answer to a question posted by you, you will earn 5 points. If your answer is selected as the best answer by the member who posted the question you will earn 10 points.

    7. If the participants of the community rate your submission for a contest entry/ article/ video/ or code with 5 out 5, you will earn 2 points for every 5 star rating, upto a maximum of 20 points. Community members will be allowed to vote only once per submission.
    8. Points will be deducted or taken away from an account should the submission be found to be inappropriate or otherwise in breach of the Intel Software Network community policy: http://softwarecommunity.intel.com/articles/eng/1517.htm

    Membership Levels and Prizes:
    The Intel Black Belt Software Developer program has 3 different membership levels with following requirements for eligibility and benefits:

    Intel Green Belt Software Developer:

    Benefit: The title 'Intel Green Belt Software Developer' recognizes a member's regular contribution to the Intel Software Network communities by having the 'Intel® Green Belt Software Developer' icon displayed on their user profile.

    Requirement: A member accumulates at least 50 points within 12 months from the date of enrolment into the Intel Black Belt Software Developer program.

    Re-qualification: A member accumulates at least 50 points within 12 months from the date of qualification as an Intel Green Belt Software Developer.

    Intel Brown Belt Software Developer:

    Benefit: The title 'Intel Brown Belt Software Developer', recognizes the value a member brings to the Intel Software Network communities by actively sharing their knowledge. These members get an 'Intel® Brown Belt Software Developer' icon displayed on their profile and also get a book of their choice from an available selection of books (approximate retail value US$70, one book per member per year, subject to availability).

    Requirement: A member accumulates at least 500 points within 12 months from the date of qualification as an Intel Green Belt Software Developer.

    Re-qualification: A member accumulates at least 500 points within 12 months from the date of qualification as an Intel Brown Belt Software Developer.

    Intel® Black Belt Software Developer: This title is awarded to a member of Intel® Software Network who is nominated to this status by an Intel panel of experts based on quality, quantity, knowledge and technical expertise that members bring to the Intel Software Network communities. The following criteria are considered for a nomination:

    * Technical expertise
    * Regular discussion forum activity
    * Guidance and support provided to other community members
    * Submission of content
    * Overall community participation.

    Benefit: This is the highest level of recognition. Each member to this tier will be appointed by the Intel panel of experts and receive the following benefits:
    1. Welcome gift: jacket OR laptop bag with Intel logo (approximate retail value: US$70)
    2. An plaque honoring their status as Intel Black Belt Software Developer on Intel Software Network communities.
    3. One laptop with a high-end Intel microprocessor available at that time (approximate retail value: US$1800; awarded only once at the first time a member qualifies as an Intel Black Belt Software Developer, not awarded for re-qualifying).
    4. Licenses to select Intel® Software Development Products: Intel C++ Compiler Professional Edition for (approximate retail value US$ 599) VTune� Performance Analyzer (approximate retail value US$ 999) Intel® Thread Checker (approximate retail value US$ 699)
    5. Free pass to Intel Developer Forum (approximate retail value varies by country: up to US$1,600),
    6. Personal profile featured on the Intel Software Network 'Hall of fame' recognition page
    7. Personal profile covered in the Intel Software Network Newsletter along with an interview/ video interview published on Intel Software Network
    8. Opportunity to meet Intel engineers at 'meet & greet' Intel events & seminars
    9. Opportunity to host a blog on Intel Software Network.


  5. Intel Black Belt Software Developer Program Spontaneous Recognition Prize: This is a spontaneous recognition award to recognize members who demonstrate exceptional community support, show commitment and encourage innovation. This is a ‘Spontaneous Thank you reward’ and there is no defined frequency or obligation to award this prize.

  6. The membership to each of these levels is valid for 12 months from the membership start date to that level. All rewards are subject to availability and they may change at any time.

  7. Points cannot be applied to the membership level until credited to the contribution account. We are not responsible for a failure, delay or error of points to be credited. If contribution points are not credited, you may contact us by writing to us at isn.support@intel.com.

  8. Points expire, if the relevant contribution account is closed or the Intel® Black Belt Software Developer program ends.

  9. A Member who continues to contribute and to collect points will be able to review the membership status and the points status online in the contribution account/ user profile.

  10. If you no longer meet the minimum required criteria for your current membership level, you will not re-qualify for your current membership status, and you will be re-assigned or downgraded to the appropriate qualifying tier of membership without notice. You will still be required to meet the downgraded level�s requirements. Your contribution account will be updated accordingly.

  11. We may, on notifying you, immediately suspend or terminate your rights, if you breach these rules, if we reasonably believe that you have dealt with points or membership status in a manner not permitted by these rules.
Courtesy: Intel Software Network Policy Document

Thursday, February 12, 2009