Professional Development with Web APIs

Download Report

Transcript Professional Development with Web APIs

Professional Development with
Web APIs
Presented To:
Indy .NET Developer’s Association
By: Denise Gosnell
[email protected]
July 14, 2005
© 2005 Denise M. Gosnell. All Rights Reserved.
Based On Topics In My New Book:
Professional Development with Web APIs

Google, eBay, PayPal, Amazon.com,
MapPoint, UPS, FedEx (April 2005)
This Presentation Is Available For
Download from
www.denisegosnell.com/news.html
The Source Code for the book is available
for download from www.wrox.com.
© 2005 Denise M. Gosnell. All Rights Reserved.
Outline of Topics
What Is A Web API?
Google API
MapPoint API
Amazon.Com APIs
eBay API
PayPal API
Other APIs
Calling From Mobile Devices and Office
Creating Your Own API
© 2005 Denise M. Gosnell. All Rights Reserved.
What Is a Web API? (Chapter 1)
Series or collection of web services
Sometimes used interchangeably with
“web services”
Examples: Google API, Amazon.Com APIs
© 2005 Denise M. Gosnell. All Rights Reserved.
How Do You Call a Web API?
XML web services can be invoked in one of
three ways:


Using REST (HTTP-GET)
URL includes parameters
Example:
http://webservices.amazon.com/onca/xml?Service=AWSECo
mmerceService&SubscriptionId=YOURIDGOESHERE&Oper
ation=ItemSearch&SearchIndex=Books&Keywords=Denise%
20Gosnell

Using HTTP-POST
You post an XML document
XML document returned

Using SOAP
More complex, allows structured and type information
© 2005 Denise M. Gosnell. All Rights Reserved.
The Google API (Chapter 2)
Available Using SOAP with HTTP
Limited to 1000 Calls Per Day
Obtain a Developer Key and Developer’s Kit
From:

www.google.com/apis/
Query Syntax:

doGoogleSearch (Key, SearchString, Start,
MaxResults, Filter, Restrict, SafeSearch, lr, ie, oe)
Returns only 10 results at a time – have to change the start
index to specify which ones to retrieve


doGetCachedPage (Key, URL)
doSpellingSuggestion (Key, Phrase)
© 2005 Denise M. Gosnell. All Rights Reserved.
The MapPoint API (Chapter 3)
Can Be Called Using SOAP with HTTP
Examples of Supported Features:






Addresses
Reverse Geocoding
Finding Nearby Places
Custom Locations
Map Rendering
Points of Interest
Evaluation Account / Developer Account:
http://www.microsoft.com/mappoint/webservice/d
efault.mspx
© 2005 Denise M. Gosnell. All Rights Reserved.
The Amazon.Com APIs (Chapter 4)
There Are Currently 3 Amazon.Com APIs



Amazon E-Commerce Service (ECS)
Alexa Web Information Service (AWIS) – programmatic access
to www.alexa.com web crawl data
Simple Queue Service
All 3 Can Be Called Using SOAP or HTTP-GET(REST)
Info About These 3 Can Be Found At:
http://www.amazon.com/gp/browse.html/102-31935827147314?%5Fencoding=UTF8&node=3435361
Sign Up For Subscription ID at:
http://www.amazon.com/gp/aws/registration/registrationform.html
Mention www.a9.com which uses one or more of
Amazon.com APIs above
© 2005 Denise M. Gosnell. All Rights Reserved.
Amazon.Com Demo
Create a New VB.NET WinForms Project
Add a reference to the Amazon.com API (Project | Add Web Reference):
http://webservices.amazon.com/AWSECommerceService/AWSECommerce
Service.wsdl
Then, add the following code to your VB.NET WinForms project:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AmazonProductData As New _
TestAmazonWebService.Amazon.AWSECommerceService
Dim AmazonSearch As New TestAmazonWebService.Amazon.ItemSearch
Dim AmazonResponse As New _
TestAmazonWebService.Amazon.ItemSearchResponse
Dim AmazonRequest(1) As _
TestAmazonWebService.Amazon.ItemSearchRequest
'Developer/Subscription Code
AmazonSearch.SubscriptionId = "YOUR ID GOES 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 with
AmazonRequest(0) = New _
TestAmazonWebService.amazon.ItemSearchRequest
AmazonRequest(0).SearchIndex = "Books"
AmazonRequest(0).Keywords = “Denise Gosnell"
© 2005 Denise M. Gosnell. All Rights Reserved.
Amazon.Com Demo (continued)
'assign the search object to the request object with the assigned parameters
AmazonSearch.Request = AmazonRequest
'run the search and populate the response
AmazonResponse = AmazonProductData.ItemSearch(AmazonSearch)
Dim item As New TestAmazonWebService.Amazon.Item
Dim strOutput As String
strOutput = "Search results for keyword(s): " & AmazonRequest(0).Keywords & " in " &
AmazonRequest(0).SearchIndex & ":" & vbCrLf & vbCrLf
'loop through the results
For Each item In AmazonResponse.Items(0).Item
strOutput = strOutput & item.ItemAttributes.Title & vbCrLf & vbCrLf
Next
'display the results in a message box
MsgBox(strOutput)
End Sub
© 2005 Denise M. Gosnell. All Rights Reserved.
The eBay API (Chapter 5)
eBay API can be called using HTTP-POST or
SOAP
Sandbox (Test) and Live Environments
Supports most popular features:





Retrieve Auction Listings
Retrieve Customer Reviews
Retrieve Status of Auction
Add New Auction Listing
Retrieve Winning Details
Join Developer Program and Obtain Account:
http://developer.ebay.com
© 2005 Denise M. Gosnell. All Rights Reserved.
The PayPal API (Chapter 6)
PayPal API can be called using SOAP
Sandbox (Test) and Live Environments
Supports several features:




GetTransactionDetails
TransactionSearch
RefundTransaction
MassPay
Join Developer Program and Obtain
Account: http://developer.paypal.com
© 2005 Denise M. Gosnell. All Rights Reserved.
Demo – Combining APIs
(from Chapter 11 Case Study)
Uses Google To Retrieve Top 5 web Sites
That Mention Your Customer
Uses MapPoint To Retrieve Map And/Or
Driving Directions To Customer Location
© 2005 Denise M. Gosnell. All Rights Reserved.
© 2005 Denise M. Gosnell. All Rights Reserved.
© 2005 Denise M. Gosnell. All Rights Reserved.
© 2005 Denise M. Gosnell. All Rights Reserved.
Other APIs (Chapter 7)
InterFax Fax API

http://www.interfax.net/en/dev/index.html
UPS API

http://www.ec.ups.com/ecommerce/gettools/prodcom
panies.html
FedEx API

http://www.fedex.com/us/solutions/wis/index.html
(some require DLLs)
Bloglines API

http://www.bloglines.com/services/
© 2005 Denise M. Gosnell. All Rights Reserved.
Finding More Web APIs
UDDI Directory

http://uddi.microsoft.com
BindingPoint Web Site

http://www.bindingpoint.com
Various Other Locations On Internet
© 2005 Denise M. Gosnell. All Rights Reserved.
Calling From Mobile Devices
(Chapter 8)
Use .NET Compact Framework In Visual
Studio.NET To Target Pocket PCs and
SmartPhones


Just Select Project Type In VS.Net
http://www.microsoft.com/windowsmobile
eMbedded Visual Tools

Use To Create Separate From VS.Net
Web Services For Palm

http://pluggedin.palmone.com/regac/pluggedin/WebS
ervices.jsp
© 2005 Denise M. Gosnell. All Rights Reserved.
Calling From Microsoft Office
(Chapter 9)
There Are At Least 3 Ways To Call Web API From
Microsoft Office Programs:
VBA

Example in Excel using VBA and HTTP/GET (REST)
VBA using SOAP

requires Web Services Toolkit (available for free
download from Microsoft)
Using .NET

requires Visual Studio Tools for Microsoft Office
System – must purchase
© 2005 Denise M. Gosnell. All Rights Reserved.
Creating Your Own APIs
(Chapter 10)
Create New ASP.NET Web Service Project from
VS.NET



Add Code
Test The Web Service Using Built-In Testing Utility In
Web Browser
Call Web Service From Another Program Using
Protocols You Enabled For Service
Can Also Convert Existing .NET App To Web
Service By Wrapping With WebMethod Attribute
© 2005 Denise M. Gosnell. All Rights Reserved.
Questions?
© 2005 Denise M. Gosnell. All Rights Reserved.