Does this method returns a url?
<p>Sorry, I'm learning so forgive me if this is a stupid question.
I got this method (updated):</p>

<pre><code>    def get_photo(self, photo_reference):
    print(self.photourl)
    print(photo_reference)
    resp = requests.get(
        url='{}{}'.format(self.photourl, photo_reference),
        params={'key': self.api_key}
    )
    try:
        return resp.json()
    except ValueError:
        print('Invalid JSON')
</code></pre>

<p>I built the requests.get with <a href="https://developers.google.com/places/web-service/photos" rel="nofollow">Google Places API - Place Photo</a>. 
In my <code>__init__(self):</code></p>

<pre><code>self.place_detail_url = 'https://maps.googleapis.com/maps/api/place/'
self.ref = 'photo?maxwidth=200&amp;photoreference='
self.photourl = self.place_detail_url + self.ref
</code></pre>

<p>I want to get photo from google place API but I tried and it returns None.
I wonder what the <code>get_photo</code> method returns and if it isnt a url. How can I encode it to a url?</p>

<p>Maybe try this (Based on your seemingly preferred approach above of building the URL yourself):</p>

<pre><code>def get_photo(self, photo_reference):
    request_url = (self.place_detail_url + self.ref + photo_reference + '&amp;key=' + self.api_key)
    output_file = (/path/to/image/here/file.png)
    with open(output_file, 'wb') as output:
        output.write(requests.get(request_url).content)
</code></pre>

python json url request google-places-api