Download - Using Web Services in Your Gadget/Widget
![Page 1: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/1.jpg)
Using Web Services in your Gadget
Alan Lewis – eBay Technical Evangelist
NGW024
![Page 2: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/2.jpg)
2 eBay Inc. confidential
Hi
![Page 3: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/3.jpg)
3 eBay Inc. confidential
I lost my voice earlier this morning
![Page 4: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/4.jpg)
4 eBay Inc. confidential
:-(
![Page 5: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/5.jpg)
5 eBay Inc. confidential
I have some cool stuff to show you though
![Page 6: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/6.jpg)
6 eBay Inc. confidential
:-)
![Page 7: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/7.jpg)
7 eBay Inc. confidential
So, I’ll give it a try
![Page 8: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/8.jpg)
8 eBay Inc. confidential
Here goes…
![Page 9: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/9.jpg)
9 eBay Inc. confidential
Huh? What’s this presentation about???
• Web Services
– You may have heard of them
– Yes, they are actually useful
– No, you don’t have to use SOAP
– Lots of services are out there for you to use (finally)
• Gadgets
– Or Widgets
– Or Plugins
– Or Panels
– Definition: “mini-applications that let you perform common tasks and provide you with fast access to information”
– Translation: They do cool stuff
![Page 10: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/10.jpg)
10 eBay Inc. confidential
Why Should I Care?
• Gadgets are cool
• Web services offer lots of reusable data and functionality
• MIXing them up (nice plug) in your gadget saves you headaches
• Alternative to doing it this way – server side coding
– Need to scale your server to handle traffic from gadget
– Different skill set required
– Eww!!!
![Page 11: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/11.jpg)
11 eBay Inc. confidential
So, what sorts of web services are out there?
• I’m so glad you asked… here is a totally random example:
eBay Web Services!!!
• Please permit me a short detour to summarize
![Page 12: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/12.jpg)
12 eBay Inc. confidential
eBay Web Service Features
• Search
• Listing Items
• Transaction/Order Management
• My eBay
• eBay Stores
• Feedback Management
• Watch List
• Bidding (with signed agreement)
• In short, almost everything you can do on the site
![Page 13: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/13.jpg)
13 eBay Inc. confidential
Different Flavors of eBay Web Services
• SOAP
• XML (HTTP POST) – Both support the same feature set (all calls)
– Calls go over HTTPS
• REST (HTTP GET)– supports GetSearchResults call
![Page 14: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/14.jpg)
14 eBay Inc. confidential
Sample Call Request
XML API:
<?xml version="1.0" encoding="utf-8"?>
<GetSearchResultsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>ABC123</eBayAuthToken>
</RequesterCredentials>
<Query>iPod Nano</Query>
</GetSearchResultsRequest>
REST API
http://rest.api.ebay.com/restapi?CallName=GetSearchResults&RequestToken=ABC123=&RequestUserId=alanlewis0&Query=iPod%20Nano&Schema=1
![Page 15: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/15.jpg)
15 eBay Inc. confidential
Sample Call Response
XML API and REST API (same response)
<?xml version="1.0" encoding="utf-8"?>
<GetSearchResultsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
…
<Item>
<ItemID>4036874357</ItemID>
…
<SellingStatus>
<BidCount>31</BidCount>
<CurrentPrice currencyID="USD">80.0</CurrentPrice>
</SellingStatus>
<Site>US</Site>
<Title>Used Apple iPod Nano MP3 Player Good Condition</Title>
…
</Item>
…
</GetSearchResultsRequest>
![Page 16: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/16.jpg)
16 eBay Inc. confidential
And Now…
Demo
![Page 17: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/17.jpg)
17 eBay Inc. confidential
Live.com
• Supports RSS feeds and Gadgets
• Gadgets are implemented in javascript + CSS
• Still alpha feel – emerging feature set and very buggy at times (especially with CSS support)
![Page 18: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/18.jpg)
18 eBay Inc. confidential
Design Philosophy
• Gadgets call for a fresh design approach
• Sort of like code for mobile devices– Limited screen real-estate
– Limited functionality/APIs
• Except not– Still coding for the browser– multiple windows/tabs, cross-browser issues
– Asynchronous interaction, more bandwidth
![Page 19: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/19.jpg)
19 eBay Inc. confidential
Challenge 1: Security Restrictions
• Calls can’t go across domains– If the gadget was served up from www.mydomain.com, can’t call api.ebay.com
• Live.com solution to this: proxy!– Supports XML data (except XHTML) and RSS feeds
– Currently only supports HTTP GET (contrary to docs – support for POST will be added in the future)
– Can’t proxy HTTPS yet, so only option for eBay is REST API
var r = Web.Network.createRequest( Web.Network.Type.XML,
searchQuery,
{proxy:"generic"},
eBaySearchCallback);
![Page 20: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/20.jpg)
20 eBay Inc. confidential
Challenge 2: Namespaces
• IE javascript engine can’t handle XML data in default namespaces
• Solution: Use ugly RegEx hack to remove namespace:
var rootText = response.responseText;
var re = /xmlns="urn:ebay:apis:eBLBaseComponents"/g;
rootText = rootText.replace(re, "");
var responseWithoutNamespaces;
if (window.ActiveXObject) {
responseWithoutNamespaces = new ActiveXObject("Microsoft.XMLDOM");
responseWithoutNamespaces.async="false";
responseWithoutNamespaces.loadXML(rootText);
}
else {
responseWithoutNamespaces = document.implementation.createDocument("","",null);
responseWithoutNamespaces.loadXML(rootText);
}
![Page 21: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/21.jpg)
21 eBay Inc. confidential
And now…
• ANNOUNCING:
• The gadget is open sourced
• Commercial software-friendly open source license: CDDL
• Yeah!
• http://searchgadget.codebase.ebay.com
• Lets go check it out…
![Page 22: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/22.jpg)
22 eBay Inc. confidential
Now More Code
• Here is the code, in-depth
![Page 23: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/23.jpg)
23 eBay Inc. confidential
Other Web Services
• Lots to choose from: www.programmableweb.com
• REST is very popular, but has limitations
• RSS feeds are web services too
![Page 24: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/24.jpg)
24 eBay Inc. confidential
Building Commercial Apps
• One issue to keep in mind is many Web services out there force non-commercial use
• Shameless plug: that’s not the case with eBay Web services
• One way to make money with your Gadget is to use an affiliate program like eBay’s:http://developer.ebay.com/affiliates
![Page 25: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/25.jpg)
25 eBay Inc. confidential
Other Gadget/Widget Platforms
• Vista Sidebar
– Bundled with Vista, but limited capabilities (thusfar)
• Yahoo! Widget Engine (Konfabulator)
– Multi-platform support, integration with Desktop still clumsy
• Apple Dashboard
– Best desktop integration, but only for OSX
• Google Desktop – (Sidebar)
– Information-rich widgets, but harder to build, bundled with a product IT departments hate
• Google Personalized Home Page
– Sorta like live.com – less functionality but better visibility
![Page 26: Using Web Services in Your Gadget/Widget](https://reader035.vdocuments.mx/reader035/viewer/2022070319/5583fc26d8b42aa82c8b4bc5/html5/thumbnails/26.jpg)
26 eBay Inc. confidential
Learn More Stuff
• More on eBay Web Services: http://developer.ebay.comIts totally free!
• eBay Developers Conference, baby!June 10-12, Mandalay Bay, Las Vegas
• Live.com eBay Gadget available in the Gallery:microsoftgadgets.com
• Open sourced at: http://searchgadget.codebase.ebay.com
• Sanaz Ahari’s presentation immediately following this one, in C/D