1
votes

I am using google places web service API and I am able to get the response for a place search. Using the photo reference id I am hitting the API to get the image (https://maps.googleapis.com/maps/api/place/photo?photoreference=....). As this API response is (302) ie. redirected to some other url. I am getting the response in binary data. response after redirection How can i use this data to append an IMG tag in my application?

encode to base64 seems to be not working. :-(

2
are you getting 400 ? or success ? i am guessing successAbdullah Al Noman
its a success. my worry is how do i use this garbage binary response data in my applicationAshi
check the answer . use the value of that data directly as image source @Alexander James and dont forget to mark as accepted if its working for youAbdullah Al Noman

2 Answers

0
votes

Use this directly in img tag that would work

collected from here

That URL returns the binary file of the image, e.g. a JPEG file. You can use that URL as the src of an tag directly.

You can use the url directly as source

**dont make api call just use that url as source **

-1
votes

I've not checked if this is counts as an API call, but you can get the redirect url with a decent http request library in whatever programming language you use. The redirect URL is itself the actual image and you could store that and not the binary. Whether this violates the terms of service is another question entirely.