Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get page feed with Facebook API Graph in Python

I'm trying to fetch facebook page information and feed/posts, and specifically the text of each post. I've registered a new test app, on Facebook for Developers, and I get client token, secret token and ID. I've not inserted any privacy link or Terms of Use link because it is a personal test. In the Graph API Explorer I get the app access token, and I'm using it. Using facebook-sdk I can get pages information via the following code:

accessToken = "xxx"
user = 'BillGates'

graph = facebook.GraphAPI(accessToken, version='2.7')

profile = graph.get_object(id=user, fields='id,name,about,link,location,hometown,website', limit=100)

So far, no problem. Now, I would want to get posts with this code:

posts = graph.get_connections(profile['id'], connection_name='posts', fields='caption,created_time,description,from,link,message,object_id,parent_id,permalink_url,picture,privacy,place,properties,shares,source,status_type,story,to,type,with_tags', limit='100')

or making a request.get() at this url:

url = "https://graph.facebook.com/v2.7/BillGates?fields=feed{caption,created_time,description,from,link,message,object_id,parent_id,permalink_url,picture,source,status_type,type}&limit=100&access_token=xxx"

but I receive this error:

facebook.GraphAPIError: (#15) Requires session when calling from a desktop app

My app has the contact email, is a native or computer application (it will run on a linux server), is public and has just email, public_profile and user_friend as approved elements. Other elements can't be approved because I've to fill notes, but I'm unable to fill them.

My idea is to request, periodically, a "general" access token, or an access token for each page I've to analyze.

Any helps would be appreciated.

like image 574
Federico Cuozzo Avatar asked May 17 '26 06:05

Federico Cuozzo


1 Answers

This problem has been solve by using {client_access_token} as access_token

url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?access_token=#{client_access_token}"
like image 74
Liam Avatar answered May 18 '26 19:05

Liam