eBay 101eBay is an online auction house that started off as an online rummage sale of sorts. All those unwanteditems in your closet could be auctioned off to someone out of state or out of the country, for that matter. eBay has evolved over the years to be a powerhouse online marketplace for new and used items. Manycompanies have their own online stores, but sell more from eBay listings than from their own privateWeb sites. One very powerful feature of eBay is the Search. You can, for example, search for all comput- ers for sale in a certain price range whose auction listings expire within a specific period of time. Fig- ure 5-1 shows an example of such a search. Figure 5-1These materials have been reproduced with the permission of eBay Inc.Copyright eBay Inc.All rights reserved. You can select a particular item and then review additional details about the item, such as one or morephotos, information about the seller, bid history, and so on. Introduction to the eBay APINow that you have a basic idea of the services offered by eBay, it s time to learn about the eBay Web API. The eBay API is an XMLWeb service that can be called in one of two ways. The first way is by usingHTTP-POST to submit an XMLdocument containing the request and to receive an XMLdocument118Chapter
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services
Using the eBay APIUnless you have been living in a cave, you have heard about eBay, and you probably have usedeBay yourself to purchase or sell items. eBay is known for inventing the online global marketplacethat brings millions of people all over the world together to sell new and used items. eBay is mak- ing it easier than ever before for you to write your own software applications using the eBay APIor the eBay SDK to interact with eBay features. You can obtain a free developer account that can beused for individual purposes in a test and production environment for a limited number of calls. You can also purchase commercial accounts if you want to write applications for others that inter- act with eBay. This chapter covers the following: .Introduction to eBay as an online global marketplace .How to set up a developer account and obtain all the necessary identifiers to use theeBayAPI .The syntax of eBay API queries .How to call the eBay API using HTTP-POST using Visual Studio .NET .How to call the eBay API using SOAPfrom Visual Studio .NET .Five examples of how to use the eBay APIs .Additional ideas for how you might use the eBay APIAs with the other APIs you have explored in this book so far, the eBay API is very comprehensiveand would take numerous chapters or perhaps an entire book to cover in detail. This chapter willhelp you set up your eBay developer account and will walk you through some simple examples toillustrate the potential ways you can use the API. You can consult the eBay documentation online, as well as the case studies later in this book, for additional information.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services
SummaryIn this chapter, you learned about various products and services offered by Amazon and its related panies. For example, you learned about the Alexa Web crawler and the A9.com search engine. You how to make use of the Amazon e-Commerce Web Service and the Alexa Web InformationService in your own programs. These Amazon APIs have various features that are well beyond the this chapter. Additional examples of using the Amazon APIs are included in some of the later chap- ters, such as in the chapters that illustrate using Web APIs from Microsoft Office, from mobile devices, and in the comprehensive case studies. So far, you have explored APIs offered by Google, Microsoft (MapPoint), and Amazon.com. Let s turn 5 where you will learn about the API offered by eBay.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services
One of my favorites is a tool at http://www.allconsuming.netthat combines results from theAmazon API, the Alexa API, a blogging API, and others in a creative way. It monitors blogs (Web logs) to see what books people are talking about, and then displays information about those books fromAmazon. An example is shown in Figure 4-13. Figure 4-13WWWinkazon (http://www.naturallyopen.com/wwwinkazon) is a browser plug-in that allows youto access Amazon.com products from any site on the Web. To use the plug-in, you highlight text on aWeb page and click on the browser s WWWinkazon icon. Apane is then opened right in your browserthat includes a list of Amazon.com products and images pertaining to the keywords you selected. Youcan click on the link to open an Amazon.com page. Feedburner (http://www.feedburner.com) is a tool that allows you to earn Amazon Associates refer- ral fees from RSS feeds by inserting relevant Amazon.com products into the feeds. You can matchAmazon stores to your own content categories, and the tool uses the Amazon ECS API to match the specific content of the RSS feeds to relevant Amazon.com products. Other parties are using the Amazon ECS API to offer complex Amazon.com searches, such as by usingthe tools available at www.pluck.comand www.hivegroup.com/amazon4.html. 114Chapter
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services
.Use the queue to store a simple list of information you want to access from anywhere (for ple: list of favorites, personal information that is not sensitive, and so on). You can then useHTTP/GET (REST) for the particular URLto retrieve the list from a Web browser from any puter in the world with an Internet connection. Third-Party Amazon ExtensionsDozens of third parties have used the ECS Web API in creative ways. You can find an extensive list some of these third parties have done on the Amazon.com Web site. The list is currently located www.amazon.com/gp/aws/samples.html/102-8555922-5718568. As one example, SellerEngine (http://www.sellerengine.com) enables Amazon Marketplace sellersto load, price, and manage their Marketplace listings directly from their desktop. As another example, Amazon.pl XMLuses the ECS Web API and allows Associates to add Amazon.com products easily Web sites. All you need to know to use the service is how to insert simple HTMLlinks into Webpages. Here are some more interesting ways third parties are using the Amazon APIs. Amazon Lite simulatesalite version of Amazon and can be found at http://kokogiak.com/amazon/, as illustrated in Fig- ure 4-12. Figure 4-12113Using
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services
#5 Retrieve URL Information with Alexa WebInformation ServiceThe following example uses the UrlInfooperation of the AWIS Web API to retrieve links of Web pagesthat are related to the www.amazon.comWeb site. http://aws-beta.amazon.com/onca/xml?Service=AlexaWebInfoService&Operation=UrlInfo&SubscriptionId=[Your Subscription ID] &Url=www.amazon.com&ResponseGroup=RelatedLinksOther Ways to Use the Amazon APIsIn the previous sections, you looked at five examples to give you an idea of how you can use theAmazon APIs in your applications. Following are some additional examples of ways you might want touse the Amazon APIs. Additional examples of the Amazon APIs are also included in the later chaptersand case studies at the end of this book. Here are examples of other ways to use the Amazon ECS Web API: .Retrieve cover art for albums .Make recommendations for other products a customer should consider .Retrieve additional data about a product based on a partial match (ISBN based on title, andsoon) .Analyze sales data from Amazon purchases for product development researchHere are examples of other ways to use the Alexa Web Information Service: .Analyze your Web site s statistics .Analyze the Web site statistics of your competitors to help point you to the companies youshould be looking at .Find out if someone is improperly linking and/or framing to your Web site. Such a featuremight be useful for attorneys and companies trying to track down infringers of intellectualproperty. Here are some creative examples of ways you might use the Simple Queue Service: .Create an application that allows users to submit requests to the queue and then check thequeue periodically to perform the requested action (for example: search Google with specifiedcriteria contained in the message in the queue). .Use the queue as a bulletin board of sorts with an application that reads the queue to allow mul- tiple people to share information with each other (for example: a to-do list, project information, and so on). 112Chapter
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services
The first step is to look up the wish list of a person by his name, e-mail address, and so on. The examplethat follows looks up a person by name. http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[Your Subscription Id Here] &Operation=ListSearch&ListType=WishList&Name=Denise%20GosnellNext, you can use the list ID that is returned in the previous search to retrieve the list content, as shownin the following section. http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[Your Subscription Id Here] &Operation=ListLookup&ListType=WishList&ListId= YQLZOK4N6RZ5&ResponseGroup=Request,ListFull#4 Create an Amazon.com Shopping Cart with ECSThe following example illustrates how easy it is to create a remote shopping cart that contains a singleitem using the CartCreatemethod of the ECS Web API. Remote shopping carts allow visitors to additems to Amazon shopping carts from their own Web sites. http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[Your Subscription Id Here] &Operation=CartCreate&Item.1.ASIN=0764584456&Item.1.Quantity=1You should consider doing an ItemLookupon the item to find price and availability before adding tocart. The following is an example: http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[Your SubscriptionId]&Operation=ItemLookup&IdType=ASIN&ItemId=0764584456&ResponseGroup=Medium,OfferFull. Upon executing this method, a Cart ID and HMAC shopping cart token are returned. These values used to work with that particular shopping cart in the future. If the product was actually not available when you attempted to add it to the cart, it is added to the cartas a rather than a in the element. After the shopping cart is finalized, you can just transfer the customer to the Amazon URLspecified PurchaseURLvalue that was returned by the CreateCartoperation. To test this for yourself, youcan run the PurchaseURLfrom the Web browser. Because you probably do not want to complete thispurchase, you may not want to run it at this time.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Inexpensive Web Hosting services
The SellerLookupmethod of the ECS Web API returns only the first five feedback records. You can usethe OfferPageparameter to retrieve additional pages. If you want to retrieve more results than are returned in a single operation, you have to write code thatloops multiple times through calling the operation. Five Creative Ways to Use the Amazon APIsIn this section, you learn five ways to use the Amazon APIs. The first four examples use the E-CommerceService (ECS), and the last one uses the Alexa Web Information Service (AWIS). For the sake of simplicity, the examples illustrate the URLfor a REST call, as opposed to SOAP. Let s jump right into the first example. #1 Retrieve Feedback about a Seller with ECSThe following example retrieves feedback about a particular seller using the SellerLookupmethod ofthe ECS Web API. http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[Your Subscription Id Here] &Operation=SellerLookup&SellerId=A35O48Y1QVX6#2 Retrieve Product Pricing with ECSThe following example retrieves pricing of Sony s new LCD using the ItemSearchmethod of the ECSWeb API. http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=[Your Subscription Id Here] &Operation=ItemSearch&SearchIndex=Electronics&Manufacturer=Sony&Keywords=LCD&Condition=New&MerchantId=All&ResponseGroup=Medium,OfferFull#3 Look Up a Friend or Family Member s Wish List with ECSYou can use the wish list feature in the ECS Web API to look up a friend or family member s wish list sothat you can purchase an item from their list. The following example looks up and retrieves a wish listusing the ListSearchand ListLookupmethods of the ECS Web API. 110Chapter
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Inexpensive Web Hosting services
9.Add the following procedure to Form1: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button1.ClickDim AmazonProductData As New AWSECommerceServiceDim AmazonSearch As New ItemSearchDim AmazonResponse As New ItemSearchResponseDim AmazonRequest(1) As ItemSearchRequest Developer/Subscription IDAmazonSearch.SubscriptionId = Insert your Subscription ID Here We are only making one request, not batching multiple requests Thus element 0 of the array is all we need to assign and work withAmazonRequest(0) = New ItemSearchRequestAmazonRequest(0).SearchIndex = Books AmazonRequest(0).Keywords = Amazon MapPoint API assign the search object to the request object with the assigned parametersAmazonSearch.Request = AmazonRequest run the search and populate the responseAmazonResponse = AmazonProductData.ItemSearch(AmazonSearch) Dim item As New ItemDim strOutput As StringstrOutput = Search results for keyword(s): & _ AmazonRequest(0).Keywords & in & _ AmazonRequest(0).SearchIndex & : & vbCrLf & vbCrLf loop through the resultsFor Each item In AmazonResponse.Items(0).ItemstrOutput = strOutput & item.ItemAttributes.Title & vbCrLf & vbCrLfNext display the results in a message boxMsgBox(strOutput) End Sub10.Input your Subscription ID on the line of code where indicated. As mentioned previously, thesevalues are provided in the information e-mail you receive when you set up your account. 11.Select File.Save All to save all changes to the project. 12.Select Debug.Start (or press F5) to run the project. 13.You should see a window similar to Figure 4-11 that displays the search results. 108Chapter
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Adult Web Hosting services
Figure 4-11At the time of this book s writing, the Amazon.com WSDLfile has a problem that requires manual cor- rection. If you receive an error message stating that CustomerReviews1 cannot be reflected, then here ishow you can work around the bug: 1. From your Visual Studio .NET Solution, double-click Web References in the Solution Explorer. 2. Double-click the WebReferenceobject and the Object Browser window will open. 3. In the left pane of the Object Browser, double-click the object with the name AmazonSearch.Amazonto expand the list. 4. Double-click the WebReferenceobject and it expands to a list of objects. 5. Double-click AWSECommerceServiceto open up the source code file that VS.NET generates fromthe WSDL. 6. Search for public class CustomerReviews1. You should see the Public Class CustomerReviews1 decla- ration. Change the TypeNamevalue to CustomerReviews1, as shown following. Public Class CustomerReviews17. You may also need to make one other correction to keep a separate error from occurring. Search for thefollowing: public request()() as string (Visual Basic) or string[][] Request; (C#). 8. If present, remove the extra parentheses or brackets. Also, remove the GetTypeparameter, so thecode looks similar to the following: _ Public Request() As String9. Save this file. Rerun your application, and the errors should be eliminated. Looping Through ResultsVarious types of Amazon API searches limit the number of results that can be returned. For example, each ItemSearchoperation of the ECS Web API returns up to ten product listings. You can use theItemPageparameter to retrieve additional pages of ten listings, up to 500 pages. If you do not specifythe ItemPageproperty, the first page of ten is returned by default.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Adult Web Hosting services