Chapter 30 Browsing the Web and WebView
One Last Bit of Flickr Data
For both ways, you need to get the URL for a photo’s Flickr page. If you look at the JSON you are
currently receiving for each photo, you can see that the photo page is not part of those results.
{
"photos": {
...,
"photo": [
{
"id": "9452133594",
"owner": "44494372@N05",
"secret": "d6d20af93e",
"server": "7365",
"farm": 8,
"title": "Low and Wisoff at Work",
"ispublic": 1,
"isfriend": 0,
"isfamily": 0,
"url_s":"https://farm8.staticflickr.com/7365/9452133594_d6d20af93e_m.jpg"
}, ...
]
},
"stat": "ok"
}
You might think that you are in for some more JSON request writing. Fortunately, that is not the case.
If you look at the “Web Page URLs” section of Flickr’s documentation at http://www.flickr.com/services/
api/misc.urls.html, you will see that you can create the URL for an individual photo’s page like so:
https://www.flickr.com/photos/user-id/photo-id
The photo-id seen here is the same as the value of the id attribute from your JSON. You are already
stashing that in mId in GalleryItem. What about user-id? If you poke around the documentation, you
will find that the owner attribute in your JSON is a user ID. So if you pull out the owner attribute, you
should be able to build the URL from your photo JSON: