Sunday, February 14, 2010

REST, XML parsing and photos

UPDATE 08/16/2010: This screencast is obsolete in Pharo 1.1. See updated screencast Display Picasa photos.



Search and retrieve photos from Picasa using its Data API Feeds.

You will learn how to
  • execute HTTP requests
  • parse answered XML documents with SAXHandler from XML-Parser package
  • download pictures
  • display pictures in a Morphic GUI

Download screencast (800x600): .mpeg 30.8 MB, .mov 51.6 MB




Load the source code:
Gofer new
   squeaksource: 'XMLSupport';
   package: 'XML-Parser';
   squeaksource: 'Pharocasts';
   package: 'Picasa';
   load.

Search photos and display them in Pharo:
|photos|
photos:=PicasaAPI new
    searchPhotos: 'miles+davis' maxResults: 3. 
PhotoWall new viewPhotos: photos.


Code samples:

Access Picasa REST API:
'http://picasaweb.google.com/data/feed/api/all?q=puppy&max-results=10' 
    asUrl retrieveContents

Download a picture and display it with SketchMorph:
(SketchMorph fromStream:
    ('http://code.google.com/p/pharo/logo'
        asUrl retrieveContents contentStream)) openInWorld 

5 comments:

  1. WTF!!!
    xD how to do a web browsr ¿?¿?

    io need help when i open my basic image with squeak it works but when i try open pharo image doesnt works, it only occurs in my macbook, in linux work perfect

    ReplyDelete
  2. thanks for an AWESOME screencast!

    ReplyDelete
  3. "The method PicasaFeedParser startElement:attributeList: has been deprecated.
    use startElement:attributes: instead"

    Why simple whan it can be complicated?

    Why run some code smoothly when you are forced to debug in a technology you are just familiarising yourself with?

    I thought Pharo etc would be a prototyping tool at least for me, but I am faced with the classic problems of free software: poor documentation, the strange thinking of unknown people who might be experts in the software but lack basic communication and teaching skills.

    Do you think serious developers have time to invest in something that they don't know if they have the resources to master?

    People, clone yourself a Steve Jobs and let him co-ordinate you!

    ReplyDelete
  4. Well, thanks for the cast. Works nice but in current images do:

    (ImageMorph fromStream: ('http://code.google.com/p/pharo/logo' asUrl retrieveContents contentStream)) openInWorld.

    instead of SketchMorph (which is something from Squeak ages :-) )

    ReplyDelete

Note: Only a member of this blog may post a comment.