Saturday, May 15, 2010

OAuth (Yahoo FireEagle) in J2ME

OAuth is an open authentication protocol. google, twiter, yahoo , facebook are using oauth for authentication of their API access.
If you want to implement any of the API that requires oauth authentication, first you have to implement oauth. Simon King wrote an OAuth library for J2ME http://github.com/simonpk/j2me-oauth/tree/master
Here i am going to explain you. User of this library for yahoo fire eagle API.
1. First of all you require
a. consumer token
b. consumer secret
c. App id.
2. Request token:
Required Parameters
oauth_consumer_key : application consumer key
oauth_callback : set this to a value of 'oob'
oauth_nonce: A random string
 oauth_timestamp:Current timestamp of the request. This value must be +-600 seconds of the current time.
 oauth_signature_method:The signature method that you use to sign the request. This can be plaintext or hmac-sha1.
 oauth_version:OAuth version (1.0)
 oauth_signature:Your shared secret.

 FireEagleConsumer fireEagleClient = FireEagleConsumer(OAUTH_CONSUMER_TOKEN, OAUTH_CONSUMER_SECRET);
 RequestToken requestToken = fireEagleClient.fetchNewRequestToken();   
2. Verification:

now user will open http://m.fireeagle.yahoo.net/oauth/mobile_auth/[YOU_APP_ID] this link on browser and enter request key manually.browser will display the verify string.
3. Access token.
requred parameters all same as request token except oauth_callback with two new parameters.
oauth_verifier : verification code keyed in by user in step 2.
oauth_token : the request_token that you obtained in step one.

 AccessToken accessToken==fireEagleClient.fetchNewAccessToken(verifier);
now user will enter the verifier string in application and application will get the access token and secret key.
This access token and secret key application will use for further api calls
you can download full midlet code of yahoo fire eagle from here.

if you want to explore more about oauth



Saturday, May 8, 2010

Google Text To Speech API.

Google text to speech API.
Google has enhanced google translator and for text to speech functionality they are using an undocumented API.
It’s a very simple API to use.
Response:translate_tts.mp3
Constraints:
1.       It’s only available for English.
2.       It’s limited to 100 characters only.
3.       It’s an unofficial API so they can change or shut down this API any time.

Yahoo! Weather API



Yahoo! Weather RSS Feed:

Yahoo is providing a free weather RSS feed API.
For using that API first you need the WOEID of the location.
There are two ways for finding WOEID of the location.

use the Yahoo! GeoPlanet service to resolve a place to a WOEID 

http://where.yahooapis.com/v1/places.q('New Delhi')?appid=[yourappidhere]

Or use the YQL service to access GeoPlanet via it's table

After getting WOEID you are ready for weather api

Request: http://weather.yahooapis.com/forecastrss?w=WOEID
Response: response will be a RSS feed.

For more details visit this page.


Yahoo API for currency exchange rate.

Yahoo is providing a undocumented currency exchange rate API.


Request: http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDINR=X
Response: in response it will return a csv file.here is the sample content of quotes.csv file.




"USDINR=X",45.61,"5/7/2010","3:11pm" 


For more details of "f" field visit this page. http://www.gummy stuff.org/Yahoo-data.htm

URL shortening services

                                                                                                                                     
What are URL shortening services?
URL shortening services help you to create a short web page address.
Suppose i have to send a google map link
After shortening this url
bit.ly: http://bit.ly/9aL4nk

You can also give your own aliases and you can create a more user friendly URL. Like
http://tinyurl.com/vivloc

Here is the list of 90+ url shortening service providers.
http://mashable.com/2008/01/08/url-shortening-services/

But personally i like tinyurl.com and bit.ly.

API:
bit.ly is providing free REST API’S for url shortening but if you are searching for a really simple url shortening api for your application, tinyurl is the answer.

So how to use tinyurl API
Response: http://tinyurl.com/36f3zv4