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

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>

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's Batch Request not picking up a JSON parameter

My goal is to create a number of ads using Facebook's Batch API : https://developers.facebook.com/docs/marketing-api/asyncrequests/v2.9
I am sending a POST request at this URL:
https://graph.facebook.com/v2.9/act_158365238/ads
I am sending 2 parameters as per the documentation:
1- access_token
2- batch
The JSON in the batch parameter looks like :
{
"method": "POST",
"relative_url": "v2.9\/act_158365238\/ads",
"attached_files": "test1",
"body": "creative={\"title\":\"Test title 1\",\"body\":\"Test body 1\",\"object_url\":\"https:\/\/apps.facebook.com\/testapp\/\", \"image_file\":\"test1.jpg\"}&targeting={\"countries\":[\"US\"]}&name=test1"
}
The Problem
When I send this request with POSTman or my PHP code, it throws the following error
{
"error": {
"message": "(#100) The parameter creative is required",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Gj2sG7N8l1f"
}
}
However when I send the exact same request via Facebook's Graph API tool, it successfully creates the ads.
According to the API Documentation provided to create creatives you should be posting to the URL "v2.9/act_187687683/adcreatives"... The fragment of the batch that you are showing is used to create an Ad.
If, as you say, your intention is to create an AdCreative then you should be using something like the above, which differs in the body from what you are using:
{
"method": "POST",
"name": "create_creative",
"relative_url": "v2.9/act_187687683/adcreatives",
"attached_files": "test1",
"body": "title=Test title&body=Test body&link_url=http://www.test12345.com&image_file=test1.jpg"
}
In the other hand, if what you are creating is an add, then you should consider referencing the AdCreative by its ID as is done in the examples, hence in the case of a creative added in the same batch you could use the relative reference to the name:
creative={\"creative_id\":\"{result=create_creative:$.id}\"}
or if it is a creative already created you can reference it by the creative_id:
creative={\"creative_id\":\"123456\"}
I think the message is a red herring -- it's not seeing your body's creative field because the OAuth isn't properly set in your POSTman requests, so it isn't parsing the body or seeing the creative field.
If you don't know how to set OAuth in POSTman, here's a good tutorial:
https://docs.brightcove.com/en/video-cloud/concepts/postman/postman.html

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?

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

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 '%'

How to query request object in Facebook graph API explorer?

I have a request Id and I'd like to get the request Id object.
When I type the request id into the graph api explorer I get this: "Unsupported get request."
Any idea how to do this?
I'd like the request objects like at the end of this example: https://developers.facebook.com/blog/post/464/
Thanks!
EDIT My code:
First I enter this in my browser:
https://www.facebook.com/dialog/apprequests?
app_id=APP_ID&
message=Facebook%20Dialogs%20are%20so%20easy!&
redirect_uri=http://www.example.com/response
Then examining the response in Chrome I can see this under Query String Parameters:
request:600744979955487
to[0]:6025656
to[1]:630243457
to[2]:100002049936997
to[3]:100003709530244
These are the Ids of the friends I sent the request to and the request ID.
I use that data to construct this request in the Graph Api Explorer
/600744979955487_6025656
I also tried:
/600744979955487
Both return:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
You need to call with the access_token
To get the full Request that includes the recipient user, you will need to append the recipient user ID:
https://graph.facebook.com/<REQUEST_OBJECT_ID>_<USER_ID>?access_token=APP_ACCESS_TOKEN
or use the recipient User Access Token:
https://graph.facebook.com/<REQUEST_OBJECT_ID>?access_token=USER_ACCESS_TOKEN
-- https://developers.facebook.com/docs/howtos/requests/