Reputation: 41
Is there a way to get the posts of public pages on Facebook such as bars, clubs etc... and display them on my app?
I am working on a social media app, and I want to post information about real-time events in bars, clubs etc... Is there a way for me to use the posts of these joints from Facebook? Those pages are all public so there is no privacy issue.
Upvotes: 3
Views: 13403
Reputation: 4200
To retrieve FB pages' posts by date, I use this function:
def queryFB (page_id, since_inp, until_inp, access_token=access_token):
""" retrieve the statuses of one page for a specified time range"""
# format since = "YYYY-MM-DD"T"HH:MM:SS+XXXX" (XXXX = time zone difference)
# format until = "YYYY-MM-DD"T"HH:MM:SS"
# format access_token = [app_id] + "|" + [app_secret]
# build URL
base = "https://graph.facebook.com/v2.11"
node = "/"
since = "since=" + str(since_inp)
plus = "&"
until = "until=" + str(until_inp)
fields = "fields=id,created_time,updated_time,message,likes.summary(True)"
token = "access_token=%s" % access_token
url = base + node + page_id + node + "posts?" + since + plus + until + plus + fields + plus + token
print(url)
(Of course, this will then need to be amended to use the output.)
Upvotes: 1
Reputation: 819
Check this endpoint of graph api: /{user-id}/posts shows only the posts that were published by this person
.
If you need an example, check this answer (implemented in python).
Any question, please do ask.
Upvotes: 2
Reputation: 460
You can use the Facebook Graph Api. Here's an example to get all the posts from Stack Overflow page on facebook (You need access token for that):
curl -i -X GET \
"https://graph.facebook.com/v2.5/officialstackoverflow/feed?access_token=[YOUR ACCESS TOKEN"
The structure of the request is:
https://graph.facebook.com/v2.5/[Facebook Entity Id]/feed
You can use the Facebook Graph Explorer tool for testing and getting temporary access token.
Upvotes: 3