Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRobert Gage-Smith
13,977 PointsFinish this code to retrieve a JSON formatted version of the Flickr Public Photo Feed:
Hi!, I'm stuck with this single question. I'm adding '?jsoncallback=?' after .gne, exactly as in the vid tutorial but I keep getting a "bummer|" message.. What am I missing?? Thanks!
Robert Gage-Smith
13,977 PointsThanks for that.
8 Answers
Iain Simmons
Treehouse Moderator 32,305 Pointscurtis is correct, you need the format parameter. The jsoncallback parameter is for getting a JSON-P response back from the API, which is similar to JSON but expects a callback function to be run on the response.
Robert Gage-Smith
13,977 PointsAh, thanks, that clears that up.
Iain Simmons
Treehouse Moderator 32,305 PointsRobert Gage-Smith, if you could select a best answer to close off this question, that'd be great!
Ishan Vyas
30,284 Points"?format=json" is correct
Iain Simmons
Treehouse Moderator 32,305 PointsThe Flickr API can return its response in a number of different formats, so you need to specify the format
parameter (sent as a query string variable in the URL) with a value of json
to get the response back in JSON format, as specified in the quiz question.
The jsoncallback
parameter is used for JSON-P responses, and the value would be the name of a function (that you would have to define beforehand) that would be 'wrapped' around the response so that it will run it with the response data.
For example, if you had a function called logMe that just logged the passed in data to the console, like so:
function logMe(data) {
console.log(data);
}
Then you could send a request to the follow URL: https://www.flickr.com/services/rest/?method=flickr.test.echo&format=json&api_key=fd67e1080666203b0ae2912246ca7a48&jsoncallback=logMe
And you would get a response similar to the following:
logMe (
{
"method": {
"_content": "flickr.test.echo"
},
"format": {
"_content": "json"
},
"api_key": {
"_content": "fd67e1080666203b0ae2912246ca7a48"
},
"jsoncallback": {
"_content": "logMe"
},
"stat": "ok"
}
)
Which would log the response object (between the first and last curly braces) to the (browser) console like so:
▼ Object {method: Object, format: Object, api_key: Object, jsoncallback: Object, stat: "ok"}
▼ api_key: Object
_content: "fd67e1080666203b0ae2912246ca7a48"
►__proto__: Object
▼ format: Object
_content: "json"
►__proto__: Object
▼ jsoncallback: Object
_content: "logMe"
►__proto__: Object
▼ method: Object
_content: "flickr.test.echo"
►__proto__: Object
stat: "ok"
►__proto__: Object
Kazim Noori
12,911 PointsHello there,
You just need to put in the blank the below info:
?format=json
Thanks, Kazim Noori
Matt Bloomer
10,608 PointsI do not understand your answer; can you please explain it a little more?
Barry Barnes
18,631 PointsTHANKS DUDER!!!!!
Sandeep Krishnan
9,730 Points"?format=json" doesnot work
Iain Simmons
Treehouse Moderator 32,305 PointsThere's a good chance the Flickr API has been updated since this question and answer were posted. If you find the new API syntax for receiving a JSON response (it might be the default now), then please share it here!
Sandeep Krishnan
9,730 PointsSure will do sir
curtis allen
28,800 Pointscurtis allen
28,800 PointsI think this is what you need.
https://api.flickr.com/services/feeds/photos_public.gne?format=json