Getting notifications of managed page using Graph API - facebook-graph-api

Is there any way to get notifications of a managed page just as it can be done for users?
For a user I'd trivially trigger a GET request to /me/notifications. I've tried doing the same for a managed page (using the access token provided by /me/accounts), that is triggering a GET to //notifications?access_token= but I get a "Unsupported get request" error message, which I guess means that the notifications connection is not available for pages.
Is there any way to get this via Graph? The web page has a notifications link/shortcut for each managed page.

Per the graph API Explorer, here are the connections you can access of the page, and unfortunately notifications is not currently on their list:
albums
events
feed
links
notes
photos
posts
questions
statuses
tagged
videos
However, you could try fql?q=
SELECT notification_id, sender_id, title_html, body_html, href
FROM notification
WHERE recipient_id=me()
EDIT
I used a valid PAGE access token and was able to get back data....
{
"data": [
{
"notification_id": "nnnnnnnnnnnn",
"sender_id": nnnnnnnnn,
"title_html": "xxxxxxx posted on Beer's timeline.",
"body_html": "",
"href": "http://www.facebook.com/permalink.php?story_fbid=nnnnnnn&id=nnnnnnnn"
}
]
}

Related

Facebook API Instagram webhook not firing

I am having trouble testing Facebook API's Instagram webhooks
Here is what I've done :
My Facebook application is validated with manage_pages, instagram_manage_insights and instagram_basic permissions
My Facebook application is "Live"
I have subscribed my app to my Facebook page POSTing on subscribed_apps endpoint (explained here: https://developers.facebook.com/docs/instagram-api/guides/webhooks/#install-app ). I already use the "feed" field. GETing subscribed_apps endpoint give the following result:
# v6.0/{my-page-id}/subscribed_apps?fields=subscribed_fields
{
"data": [
{
"id": "{my-app-id}",
"subscribed_fields": [
"feed" // the missing "instagram" here seems normal as it is not handled by API
]
}
]
}
Using ngrok I am trying to test the webhook on my local machine. I correctly receive the "test" data (using app dashboard button) but nothing happen when I subscribe to the webhook
I don't understand what I am missing here. The feed webhook I also subscribed too, works perfectly.
UPDATE
I managed to recieve the "story_insights" hooks, so I guess my configuration is OK. But I still don’t get any incoming comment or mention. Are thesi features still available in new graph api versions ?

Search for pages via Graph API, response empty

When I send the request search?type=page&q=test&access_token=[access_token] to Graph API, the response is empty data. Is there a problem with the access token or is there something missing from the request URI? I also can't seem to find a comprehensive documentation of the search method, only that for places search.
This is the response I'm getting:
{
"data": [
]
}
Facebook made a lot of changes recently:
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
You can no longer use the /search endpoint with the following object
types:
event
group
page
user
Try this instead :
https://graph.facebook.com/pages/search?q=[PageName]&fields=id,name,link,location&access_token=[access_token]
it worked for me

Facebook not giving useful information in webhook

I have implemented Facebook webhook successfully by https://developers.facebook.com/docs/graph-api/webhooks/
I have subscribed to But it is missing useful information, It gives me following response
The JSON is for example:
{
"object":"user",
"entry":[{
"uid":"1408932149",
"id":"1408932149",
"time":1370253930,
"changed_fields":["feed"]
}]
}
But I want to track what actions happen on user's post which posted by my application. Here on every action it gives me feed in changed_fields. Its pretty useless for me
Basically I want to track like, comment and share of the posts for users in real time which shared from my software/app. I have subscribed to this reference https://developers.facebook.com/docs/graph-api/webhooks/reference/user/
I know for page it is working through webhook but how can I track user's post data with the webhook?
Can anyone suggest where I am doing wrong?

why does posting to facebook page yield "user hasn't authorized the application"

I have read the fb docs and written code to publish a message to a facebook "page", however I am getting an error that I don't expect to see:
(#200) The user hasn't authorized the application to perform this action
Here's what I've done:
I set up a facebook application, which provides my APP_ID and
APP_SECRET.
I set up a test facebook "page". Let us refer to its fb id as PAGE_ID.
Used OAuth to get a USER_ACCESS_TOKEN with scope "publish_actions,manage_pages" for the user. I accepted the permissions requested by my app when redirected to the facebook auth page.
I did a GET on https://graph.facebook.com/me/accounts using the USER_ACCESS_TOKEN, and I get back a list of pages I administrate, including the one I want to post to.
This block of data for my page looks like:
{
"data": [
{
"category": "Community",
"name": "My Generic Test Page",
"access_token": PAGE_ACCESS_TOKEN,
"id": PAGE_ID,
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
....
]
}
Then I use the PAGE_ACCESS_TOKEN to post a message to the page:
I did a POST on https://graph.facebook.com/PAGE_ID/feed with a field message equal to This is a test post.
Facebook returns:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
Using the token debugger, I can confirm that my PAGE_ACCESS_TOKEN is valid, and has scopes: manage_pages and publish_actions.
Where am I missing authorizing the application? Do I need additional scopes? Did I miss clicking something on the facebook authorization screen? Is there a setting on the app I am missing? After days of debugging this, I must be blind to the problem. :-|
You should add permission called status_update, for example
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=145634995501895&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html%3Fdisplay%3Dpage&response_type=token&fbconnect=1&perms=status_update&from_login=1&m_sess=1&rcount=1
and i'm able post to page i liked with the access token i get just now:
If you want to post as the admin of the page, you're require both manage_pages and status_update permissions, for example
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=145634995501895&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html%3Fdisplay%3Dpage&response_type=token&fbconnect=1&perms=manage_pages%2Cstatus_update&from_login=1&m_sess=1&rcount=1
Cheers
status_update is not used anymore. To publish on pages, I had to use both manage_pages and publish_pages.
Well, this seems to be a common mistake that most of us make while trying to do an activity in social netwroks. Before trying to put up an open graph action,You need to set the permissions in your initial authorization request . By default you only gain 'read-only' access to their basic information.
Settintg up permisson at teh time of authetication is a must for Facebook and LinkedIn APIs..
See the public_actions section in Facebook open graph permissions here and make relevant changes in the authorization code , and get your issue solved.
I found the best way to get a valid token and check permissions was via the Graph API Explorer BUT while Facebook's documentation is extensive it is not always the easiest to follow.
In the explorer you have to look at both:
The Application Currently at the top and quite subtle, I missed this for ages.
Get Token Dropdown What you click to get a Token, when you click the arrow you can choose pages and other items you have access to for selecting a token for.

GET news feed FROM stream TABLE

I am trying to send request for newsfeed to fql through Graph API Explorer on developers page, I am surprised to see that response i got doesn't match fully the news feed on facebook page also the news feed on ios app for facebook. It gets more confusing when i post request through url which responses with totally different list in XML, which shows something extra which doesn't show on my news feed on facebook page.
the query i send with fql from Graph API Explorer
SELECT post_id, actor_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0
and through URL i send
https://api.facebook.com/method/fql.query?query=SELECT%20post_id%2C%20actor_id%2C%20target_id%2C%20message%20FROM%20stream%20WHERE%20filter_key%20in%20(SELECT%20filter_key%20FROM%20stream_filter%20WHERE%20uid%3Dme()%20AND%20type%3D'newsfeed')%20AND%20is_hidden%20%3D%200&access_token=<access token>
I am searching for answer for a week now an i didn't find nothing useful, tried this from other account and i see same problem.
I tryed also to see what facebook app for ios request and i got a link which looks like this
https://graph.facebook.com/graphql/
with a POST parameters
sdk_version=3
format=json
app_version=40121
q=node(1033280756){home_stories.environment(iphone).first(5){edges{deduplication_key,...<in very long query>
locale=en_US
method=get
sdk=ios
access_token=<access token>
but testing it with Graph API Explorer with access token from GAE i recieve message
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: graphql",
"type": "OAuthException",
"code": 803
}
}
this only works and response totally match my news feed from facebook page when i gave access token from my ios facebook app and when i try to get access token through https://www.facebook.com/login.php?api_key=6628568379 i receive the same error.
I cant understand is this a bug in table or this isnt the way how you get news feed like facebook gets?
Did anybody got any official answer from facebook?