Python Facebook SDK: How to get response from request?
<p>I am using the following code to publish photo but I don't know how to get response ID post. How to get it ?</p>

<pre><code>import facebook

graph = facebook.GraphAPI(access_token='mytoken', version='2.7')

graph.put_photo(image=open(r'E:\Facebook\myphoto.jpg', 'rb'), message='Cool'.encode('utf-8')) 
</code></pre>

<p>Also, Facebook doesn't show photo in wall. It shows "no automatic alt text available". So, how to publish photo correctly ?</p>

<p>Thank you :)</p>

<p>According to the documentation <a href="http://facebook-sdk.readthedocs.io/en/latest/api.html#put-photo" rel="nofollow"><code>put_photo()</code></a> should return JSON containing the ID and the post ID, however, it actually returns a dictionary, i.e the JSON has been decoded for you. Try this:</p>

<pre><code>import json
import facebook

graph = facebook.GraphAPI(access_token='mytoken', version='2.7')
photo = graph.put_photo(image=open(r'E:\Facebook\myphoto.jpg', 'rb'), message='Cool'.encode('utf-8')) 
print(photo)
print('id: {}'.format(photo['id']))
print('photo_id: {}'.format(photo['post_id']))
</code></pre>

python facebook facebook-graph-api