How to query request object in Facebook graph API explorer? - facebook

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/

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

"message": "Unsupported post request. Object with ID does not exist, cannot be loaded due to missing permissions

I have two apps on facebook. In one, I can make API calls. In the other, I can not.
I checked the configuration and the settings are the same.
Can you help me?
Example: https://graph.facebook.com/860599774051206/?access_token=APP_ID|APP_SECRET
https://graph.facebook.com/860599774051206/notifications?template=#[860599774051206]test&access_token=APP_ID|APP_SECRET&method=post
the error is:
{ "error": { "message": "Unsupported post request. Object with ID
'860599774051206' does not exist, cannot be loaded due to missing
permissions, or does not support this operation. Please read the Graph
API documentation at developers.facebook.com/docs/graph-api",
"type": "GraphMethodException", "code": 100, "fbtrace_id":
"BRW7BqFeEER" } }
RESOLVED:
Any app can change the user_id
In an app the user_id is 962084030569446, in the other 860599774051206
Thakns for all.
I faced this issue when I was trying to post a response to an user from a page. I used the graph API me/accounts and got the list of pages. From there I retrieved the access_token of the page from which I'm going to post the response. I got the same error mentioned in the question.
The issue for me is the user account to which I was supposed to respond is locked due to security. This is the error I got from facebook when I tried to login
You can't use Facebook at the moment
This is the error I got for the post api call
{
"error": {
"message": "Unsupported post request. Object with ID 'xxx' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "yyy"
}
}
Once the account security is resolved, the issue is resolved.
While unrelated to the OP problem I thought I would contribute, I got this error when posting to the Offline Events endpoint https://graph.facebook.com/v2.8/<business_id>/events. I had posted from a node.js app successfully, then when porting the approach to a .Net implementation in our Linnworks order management system, got this error.
Turned out, I had mis-typed the access_token parameter that goes in the form data, i.e.
System.Collections.Specialized.NameValueCollection formFields = new System.Collections.Specialized.NameValueCollection();
formFields.Add("accessToken", accessToken);
formFields.Add("upload_tag", "store_data");
formFields.Add("data", data);
Should have been:
System.Collections.Specialized.NameValueCollection formFields = new System.Collections.Specialized.NameValueCollection();
formFields.Add("access_token", accessToken);
formFields.Add("upload_tag", "store_data");
formFields.Add("data", data);
Getting the access_token field wrong in this way caused this 'Object with ID does not exist' which is a bit of a red herring. I guess that, once the access_token value was not provided, no objects could be enumerated in our account because the request didn't authenticate in order to provide permissions, and so the object was 'not found'
(you do not have to use NameValueCollection, this is just a by-product of me using the multipart post implementation suggested here Upload files with HTTPWebrequest (multipart/form-data))
In my case - I had to use the app-id to get the list of pages using me/accounts.
Once I identify the page that I want to post the message to, I have to use the page-id to feed page-id/feed.
This solved the issue.
For example:
$response = $fb->get('/me/accounts', (string)$selBehRow1["fb_app_access_token"]);
foreach ($response->getDecodedBody() as $allPages)
{
foreach ($allPages as $page )
{
if (isset($page['id']) && $page['id'] == $selBehRow1['fb_page_id'])
{ // Suppose you save it as this variable
$appAccessToken = (string) $page['access_token'];
break;
}
}
}
$response = $fb->post(
//this is wrong: '/'.$selBehRow1["fb_app_id"].'/feed',
'/'.$selBehRow1["fb_page_id"].'/feed',
array(
"message" => "$msg",
"link" => "$link",
//"picture" => "http://www.example.net/images/example.png",
"name" => "$name",
"caption" => "$caption",
"description" => "$description"
),
$appAccessToken
);
}
i think post_id is wrong you can check it once
https://graph.facebook.com/860599774051206_4548643168486465/?access_token=APP_ID|APP_SECRET
https://developers.facebook.com/docs/graph-api/reference/v3.3/object/comments
use this api for replies to the post
Method: POST
https://graph.facebook.com/860599774051206_4548643168486465/comments?access_token=APP_ID|APP_SECRET
body:
{
"message": "Thanks"
}
You need to use GET request instead POST. Look at the documentation
In my case I needed to Complete Setup

How to retrieve attachments from Facebook Graph API?

I'm struggling to find a method to retrieve attachments from a message via the Graph API.
When I request the message (m_mid.xxxxxx/attachments), I get the response:
"data": [
{
"id": "105446924xxxxxx",
"mime_type": "application/pdf",
"name": "some.pdf",
"size": 89628
}
]
Any way to get the attachment link or the file itself?
The documentation only lists four fields that you can use as query parameters to filter the results, and these are the same as the response to your request.
However, if you remove the fields parameter from the request, you'll also get an image_data object which includes URLs.
For example:
https://graph.facebook.com/v5.0/{message_id}/attachments?access_token={page_access_token}