Home > javafx > Making JavaFX InterestingPhotos… Interesting!

Making JavaFX InterestingPhotos… Interesting!

InterestingPhotos is one of JavaFX sample published at samples website. It displays “interesting” photos from flickr [List of interesting photos for the most recent day].
It uses flickr api – flickr.interestingness.getList
Does it sound interesting to you? May be not.. It would have been nice if it could display photos from my flickr id!
Ofcourse yes! It can! For that you need to do some minor modifications to the source code. First download the InterestingPhotos source from http://javafx.com/samples/InterestingPhotos/.
Obtain a flickr api-key from flickr website. You need to login to the site with your flickr id and apply for a new key. You will receive a key similar to 1234567890abcdef0123456789abcdef.
Now you need to find user-id (nsid) of your flickr user-name. It can be found from flickr website. Visit flickr.people.findByUsername. Enter your user name in the text field. Click “Call Method…” button. It will display an XML output below. Note down the nsid in the output, similar to nsid=”1234567@A01″.
You can get the list of public photos in your flickr account using flickr.people.getPublicPhotos api. You need to specify the above nsid as user_id argument.
Example: http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=1234567890abcdef0123456789abcdef&user_id=1234567@A01
Open the above URL, it must list the photo information in XML format.
Below code is in Main.fx of InterestingPhotos.

// Submit HttpRequest    
var request: HttpRequest = HttpRequest {
    location: "http://api.flickr.com/services/rest/?method="
    method: HttpRequest.GET

Modify the location: URL to point to above obtained URL. Rebuild the application. Now it must show photos from your flickr account!

For Applet mode, click on above image
For standalone mode

var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/making_javafx_interestingphotos_interesting”;
var dzone_style = ‘2’;

Categories: javafx Tags: ,
  1. March 3, 2009 at 10:11 PM

    nice explanation! where can i get a list of web services like flickr, twitter..?

  2. March 3, 2009 at 10:48 PM

    Thanks Jose. You need to visit respective provider website to get information on the APIs. Also they may have Java API implementation which can be directly used in FX application.

  3. April 6, 2009 at 11:17 PM
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: