Facebook Graph API: The "Next" link for "Paging" is not working - facebook

I'm getting the feed from a page through the Facebook Graph API. At the end there is a link given, in order to retrieve the next page of the feed, as shown here (I removed my access token):
"paging": {
"previous": "https://graph.facebook.com/v2.8/14408401557/feed?fields=from,message,link,created_time,type,name,id,comments.limit\u0025280\u002529.summary\u002528true\u002529,shares,reactions.limit\u0025280\u002529.summary\u002528true\u002529&limit=100&since=1483025111&access_token=XXX|XXX&__paging_token=enc_AdABZBt6ZC7DctahZAsXG9wOUghwu8tMLYo1ZAlMdLcVCwa8VqVjBEsZABFiLRSVlA96xTQzKkrnd2ALIlGrGLhZALSum7&__previous=1",
"next": "https://graph.facebook.com/v2.8/14408401557/feed?fields=from,message,link,created_time,type,name,id,comments.limit\u0025280\u002529.summary\u002528true\u002529,shares,reactions.limit\u0025280\u002529.summary\u002528true\u002529&limit=100&access_token=XXX|XXX&__paging_token=enc_AdBOFdepWf3pcZBDLiV0r00WXJZA8qN7iYCZCzrwSoZCxYuKnHvXVUyCp35KCz4CW35p0gsmQV3Vzs5xKXe16QyCKMEN"
If I try to use the given url, I get the following error:
"error": {
"message": "Syntax error \"Expected \")\", got end of string\" at character 171: from,message,link,created_time,type,name,id,comments.limit(u0025280\\u002529.summary\\u002528true\\u002529,shares,reactions.limit\\u0025280\\u002529.summary\\u002528true\\u002529",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "Dxf6QrEjBl6"
}
Does anybody know why?

They seem to be encoded fine as output of JSON. But my guess is you are not decoding them before using. e.g.
comments.limit\u0025280\u002529.summary\u002528true\u002529
e.g. if you replace manually it works
comments.limit%280%29.summary%28true%29
See this answer https://stackoverflow.com/a/3020108/1542667 for an explanation of JSON encoding of strings, \u0025 is just '%'

Related

Facebook Marketing API returns error on "breakdowns call"

I'm trying to make an API call with the folowing URL
act_XXXXXXXX/insights?fields=ad_id,clicks,unique_clicks,impressions,reach,spend,date_start,date_stop,actions,action_values,unique_actions,account_id&level=ad&breakdowns=platform_position&time_range={"since":"2019-09-07","until":"2019-09-07"}
and the response is :
{
"error": {
"message": "(#100) Current combination of data breakdown columns (action_type, platform_position) is invalid ",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "XXXXXXXXXXXXXXXXXXXX"
}
}
the reason is in "breakdown" value = "platform_position"
but the problem is that I need exactly that breakdown :(
when I do an API call and change "breakdown" in URL to something else, for example to "publisher_platform":
act_XXXXXXX/insights?fields=ad_id,clicks,unique_clicks,impressions,reach,spend,date_start,date_stop,actions,action_values,unique_actions,account_id&level=ad&breakdowns=publisher_platform&time_range={"since":"2019-09-07","until":"2019-09-07"}
it is OK and responds with data.
I don't know why it happens because I'm not specifying any "action_type" breakdown but it tells that I am :(
What I've tried:
I tried to remove all the parameters from that URL one by one but it still returns an error
The main questions are: why the API call for "breakdown" value = "platform_position" fails and how to make it work.
Thanks.
PS: you can use FB API testing tool to test requests to FB api.
I'm using API version v8.0
You will need both publisher and position:
breakdowns=publisher_platform,platform_position

Facebook Graph API - How to get scheduler post's all detail in graph API

I'm new in facebook graph API, I want to get all the details of scheduler post like
full_picture
message
etc
I used :
GET v4.0/...?fields={fieldname_of_type_ScheduledPost} HTTP/1.1
Host: graph.facebook.com
But, I got error :
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: ...",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "A-aQAYXFbAdSX7oMYfcUP_3"
}
}
Ref., https://developers.facebook.com/docs/graph-api/reference/scheduled-post/
The brackets and dots are just placeholders.
Wrong
fields={id,message,...}
Correct
fields=id,message,...
Also, you have to use the ID of a scheduled post instead of just using "..." in the API call.
To get all scheduled posts, use this endpoint: https://developers.facebook.com/docs/graph-api/reference/page/scheduled_posts/
Example:
/me/scheduled_posts?fields=id,message&access_token=<your-page-token>

Facebook Graph: unable to get group feed

I'm trying to get the group feed via Facebook Graph API.
According to the documentation
https://developers.facebook.com/docs/graph-api/reference/v2.8/group/feed
I'm trying to costruct the appropiate url and here it is
https://graph.facebook.com/v2.8/154205721275156/feed?access_token=[TOKEN]
And each and every time I'm getting the next result
{ "error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1,
"fbtrace_id": "B7/12QU7BW/"
} }
[TOKEN] is valid, it applies to the member of the group.
At the same time other requests for the same group, such as "/events" or "/members", return correct answers.
What is wrong with the "/feed" request?

PAGE_ID/insights/page_fans/lifetime?until=DATE gives OAuthException for some dates

For some of my fanpages, it gives OAuth error , once you try to get data using /PAGE_ID/insights/page_fans/lifetime Facebook API.
What excatly happened was, I used PAGE_ID/insights/page_fans/lifetime?until=2013-05-04. It pulling through data. But if I use PAGE_ID/insights/page_fans/lifetime?until=2013-05-03 , that means same query a day before the first query, it gives
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
Does any have proper explanation for this?
you cannot use date range in /insights/page_fans/lifetime
query it without any parameters
you can combine
/insights/page_fans/lifetime
/insights/page_fan_removes
/insights/page_fan_adds
to get a daily reading

How to deal with URLs with commas in Facebook Graph API

I would like to use Graph API to get some information about URLs.
It works like this:
http://graph.facebook.com/?ids=URL,URL2,URL3
However, when an URL contains comma, things get complicated. For
http://www.example.com/name,something
we get
http://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2Fname%2Csomething
what gives us:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: something",
"type": "OAuthException",
"code": 803
}
}
What can be done with URLs to avoid such errors?
Just double-URL-encode the comma, so use %252C for it:
http://graph.facebook.com/?ids=http%3A%2F%2Fwww.example.com%2Fname%252Csomething
It might look weird, because then the Graph API identifies this URL by http://www.example.com/name\u00252Csomething - but I just tested it by pointing a like button to a URL containing a comma (un-encoded), liked it – and afterwards it showed 1 share for this URL on the Graph.