Get posts from my page using facebook api

192 views
Skip to first unread message

Marco Polo

unread,
Apr 12, 2020, 8:32:39 PM4/12/20
to PythonForFacebook
Enter code here...

I have the following code. It works fine. It gets the basic info of my page.

import facebook

page_token
= 'XXX'
graph
= facebook.GraphAPI(access_token=page_token, version="2.12")
page_id
= '#####'
print(graph.get_object(id=page_id, fields='about, category'))

graph
= facebook.GraphAPI(access_token=page_token, version="3.1")
default_info
= graph.get_object(id=page_id)
# pages_data = graph.get_object("/me/permissions")
print(default_info)
page_impressions
= graph.get_connections(id=page_id,
                                         connection_name
='insights',
                                         metric
='page_impressions',
                                         date_preset
='yesterday',
                                         period
='week',
                                         show_description_from_api_doc
=True)


I added the follow to get a post

posts1 = graph.get_object(id=page_id, fields='posts.fields(type, name, created_time, object_id)').limit(1)
print(posts1)


Then I got this error

GraphAPIError: (#12) type field is deprecated for versions v3.3 and higher




Martey Dodoo

unread,
Apr 16, 2020, 1:48:07 PM4/16/20
to pythonfo...@googlegroups.com
It's not clear from your previous message what your question is, but https://developers.facebook.com/docs/graph-api/changelog/version3.3/#pages explains how to retrieve type and other deprecated Page fields.

--
You received this message because you are subscribed to the Google Groups "PythonForFacebook" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonforfaceb...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pythonforfacebook/e3a17446-4db2-4677-87ce-cd8d7f13d5ce%40googlegroups.com.


--
Martey Dodoo
Principal Developer, Mobolic
Reply all
Reply to author
Forward
0 new messages