Question

I am using the Google API to load images in my iPhone app. I can perform the first request and then I get a JSON with a reply from Google. At first, I'd like to load a small version of the image (a thumbnail) so the user can have an idea of what the image is like. However, the url provided for the key tbUrl is weird and I can't build a NSURL with the string provided. As a consequence, I'm unable to load the thumbnail.

What I'm trying:

1) I'm making the first request (searching for "monkey)"

https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey

2) I get a JSON as reply. It has an array of "GsearchResultClass":"GimageSearch" objects. Each object has this key, which is the thumbnail URL

"tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcRpZyXXWBk0TJuU6PCdvrgrU7QckCJQ5DP96iyLc6uLx1bQn4EvBZDFLCk"

3) I just can't use this value to build a NSURL and load the thumbnail.

How can I load the thumbnail provided the URL for the key tbUrl?

Was it helpful?

Solution

I think I got the solution. What I had to do is replace the "\u003d" with "="

"tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcRpZyXXWBk0TJuU6PCdvrgrU7QckCJQ5DP96iyLc6uLx1bQn4EvBZDFLCk"

becomes

"tbUrl":"http://t1.gstatic.com/images?q=tbn:ANd9GcRpZyXXWBk0TJuU6PCdvrgrU7QckCJQ5DP96iyLc6uLx1bQn4EvBZDFLCk"

Hope it helps other people who faced the same issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top