HTML and CSS Reference
In-Depth Information
The heart of the Flickr application is inside the body of the flickrApp.parseFeed method. Here's its
implementation:
flickrApp.parseFeed = function (json) {
var pictures = JSON.parse(json);
for (var i = 0; i < pictures.items.length; i++) {
var pictureElement = {};
pictureElement.photoUrl = pictures.items[i].media.m;
// Bind to the listview
...
}
}
The JSON string you receive has the following form:
{
"title": "Recent Uploads tagged tennis",
"link": "http://www.flickr.com/photos/tags/tennis/",
"description": "",
"modified": "2012-11-30T07:56:42Z",
"generator": "http://www.flickr.com/",
"items": [
{
"title": "...",
"link": "http://www.flickr.com/photos/craftydogma/8232121888/",
"media": {
"m": http://farm9.staticflickr.com/8350/8232121888_9f762d7e5e_m.jpg
},
"date_taken": "2012-05-05T19:04:48-08:00",
"description": "<p> ... </p>",
"published": "2012-11-30T07: 56: 42Z",
"author": "...",
"author_id": "...",
"tags": "tennis vintage photo"
}
]
}
To access the URL of the photo, you need the following expression:
pictureElement.photoUrl = pictures.items[i].media.m
You can gather the photo URL, as well as other information such as date and description, into a
handy data structure—the pictureElement object of the sample above.
Search WWH ::




Custom Search