Reputation: 1599
i am trying to get the post data by using FB's Marketing API, but the error comes up:
KeyError: 'posts'
which is the 'posts'in line 6.
Below is my code, and i hided my id with xxx,
page_id = "id=xxx"
recent_2_posts = graph.get_object(id=xxx,
field='posts.fields(type, name, created_time, object_id).limit(2)')
post_1 = recent_2_posts['posts']['data'][0]
post_2 = recent_2_posts['posts']['data'][1]
print(post_1)
print(post_2)
Would anyone please assist. Thank you.
Upvotes: 0
Views: 94
Reputation: 2076
Check whether you getting data in "recent_2_posts"
. It must be blank or it will not have key name posts
Upvotes: 1