Dr. Mark Humphrys

School of Computing. Dublin City University.

Online coding site: Ancient Brain

coders   JavaScript worlds

Search:

Free AI exercises


Lab - SOAP using Flickr API

  


Demo

  1. Register with Flickr: Login and request an API key. Insert your API key into XML below.
  2. Construct SOAP version of flickr.photos.search request:

    
    <s:Envelope
    	xmlns:s="http://www.w3.org/2003/05/soap-envelope"
    	xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    	xmlns:xsd="http://www.w3.org/1999/XMLSchema" >
    	<s:Body>
    		<x:FlickrRequest xmlns:x="urn:flickr">
    			<method>flickr.photos.search</method>
    			<api_key>YOURAPIKEY</api_key>
    			<per_page>10</per_page>
    			<tags>dublin</tags>
    			<user_id>nlireland</user_id>
    		</x:FlickrRequest>
    	</s:Body>
    </s:Envelope>
    
    

  3. Send it by HTTP POST to Flickr server. Many ways to do this, in any programming language.
    To do it on Linux command-line:
      
    wget  --post-file=file.xml    https://api.flickr.com/services/soap/  -O -
    
    

  4. A search is conducted on the server for the tag "dublin" in the image stream of the National Library of Ireland on Flickr.
  5. XML is returned containing the payload like:
     <x:FlickrResponse>
     "escaped" payload
     </x:FlickrResponse>
    
  6. The payload is in "escaped" form.
    e.g. The "<" symbol is encoded as "&lt;" so it is not interpreted.
  7. Quick way to decode it: Paste it into web page and view web page in browser.
  8. When decoded the payload looks like:

    
    <photos page="1" pages="27" perpage="10" total="265">
            <photo id="25369561135" owner="47290943@N03" secret="7e0c25c5c4" server="1473" farm="2" title="Yacht : commissioned by Mrs. Stanley Lyons, 62 Leinster Road, Rathmines" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24882456989" owner="47290943@N03" secret="59587db6c5" server="1561" farm="2" title="116 St James's Street - Probably Guinness owned" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="25136980491" owner="47290943@N03" secret="0dce82938e" server="1594" farm="2" title="General Lord Roberts AKA &quot;Bobs&quot;" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24827934060" owner="47290943@N03" secret="4371435908" server="1585" farm="2" title="Abbey Street corner, Hibernian Bank shelled" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24663802585" owner="47290943@N03" secret="a2b08571e0" server="1483" farm="2" title="Informers Corridor, Kilmainham Jail." ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24407203662" owner="47290943@N03" secret="1cfa313b5a" server="1583" farm="2" title="No cars allowed and mind the horses!" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24469972256" owner="47290943@N03" secret="9f1407ab25" server="1591" farm="2" title="Thomas MacDonagh in uniform, half-length portrait" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24108838749" owner="47290943@N03" secret="0402bde306" server="1540" farm="2" title="George's Hill Presentation Convent, Dublin City, Co. Dublin" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="23826748744" owner="47290943@N03" secret="bdc3e8e259" server="1575" farm="2" title="T'would put you off the drink!" ispublic="1" isfriend="0" isfamily="0" />
            <photo id="24282897162" owner="47290943@N03" secret="e390eef2ff" server="1482" farm="2" title="Michael's Lane, Dublin City" ispublic="1" isfriend="0" isfamily="0" />
    </photos>
    
    

  9. This can be parsed by your program.
  10. Each image has various properties. From these properties you can construct URLs of image home page, various sizes of JPEG, etc.
  11. Exercise: Make a SOAP request. Get a list of images. Construct URL for one image. Embed image in your page.