简体   繁体   中英

Getting page info - facebook graph api with python

I'm relatively new to the facebook graph api. I'm the owner of a business page and I want to get some information about the fan (interest - pages they likes). How can I achieve that? This is what I wrote until this moment:

api_endpoint = "https://graph.facebook.com/v2.10/"
page_id = "1627395454223846"
node='/'+ page_id + '/insights/page_impressions'
url = api_endpoint+node

Now I create the graph object:

graph = facebook.GraphAPI(access_token=access["token"], version = 2.10)

I have had in mind to use requests but how?

I have to use it withe the graph object.

Thanks

Using requests for this I think is preferred to be honest.

import requests

payload = {'access_token': access['token']}

api_endpoint = 'https://graph.facebook.com/v2.10'
page_id = '1627395454223846'
url = '{}/{}/insights/page_impressions'.format(api_endpoint, page_id)

resp = requests.get(url, params = payload)

...process data as you wish...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM