1

I am new to Python and Facebook-Graph API. I studied about it and successfully used the Facebook-Python SDK.

First of all i got an access token from this API Explorer tool and ran few commands and everything worked without any issue. I ran the command to see my profile and my posts and then i tried to see the likes of that post. I can see the likes count and can count them too.

if('likes' in post):
    likes = post['likes']
    while True:
        try:
            total_likes = total_likes + len(likes['data'])
            likes = requests.get(likes['paging']['next']).json()

        except KeyError:
            break
else:
            print "No likes on the post"

Then i used extended access token and installed one app in my facebook account and used this method to extend the session.

graph = facebook.GraphAPI(user_short_lived_token_from_client)
app_id = 'app_id' # Obtained from https://developers.facebook.com/
app_secret = 'app_secret' # Obtained from https://developers.facebook.com/

# Extend the expiration time of a valid OAuth access token.
extended_token = graph.extend_access_token(app_id, app_secret)
print extended_token #verify that it expires in 60 days

I can see that i got 60 days extension by the above method. I used that extended access token and put it in Facebook Graph Explorer tool and extended it and granted all the permissions. Now when here i am running the same code to find the likes, it is giving me error that there is no key with the name of `likes'. When i printed the post, there are only few keys, i.e.

  1. Created time
  2. Message
  3. Id

I used the same access token on Graph API explorer and i can see all the keys and values but when i am using the same token via python sdk, i can see only 3 keys.

Any hint about it?

Rao
  • 125
  • 1
  • 5
  • Most likely simply due to different API versions being used; since API v2.4 you need to ask for the fields you want, see the duplicate. – CBroe Apr 18 '17 at 09:36

0 Answers0