Facebook marketing api access non existing field - facebook

I am trying to access campaigns of the facebook account. Using python lib: https://github.com/facebook/facebook-python-ads-sdk
Receive error: (#100) Tried accessing nonexisting field (campaigns) on node type (AdAccount)
Url: https://graph.facebook.com/v2.11/{account_id}/campaigns
Everything worked fine for months. Now, even facebook page for this url is empty: https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns/
Any thoughts, what's the problem?

Seems to be a bug.
Reported here: https://developers.facebook.com/bugs/707332642990208/
Works perfectly without time_range param.
So, could be temporary solution.

I don't know if this is a bug or not: facebook does this from time to time and is implementing check routines for parameters - in fact "adaccounts don't have any parameters:facebook api reference adaccount reading)
The error you are getting (#100) says "invalid parameter" (facebook reference adaccount validation rules), this is, because you may have defined the time_range and you are asking api for campaigns in an adaccount. But: for adaccount edge time_rage parameter is invalid.
The solution is to FIRST asking api for https://graph.facebook.com/v2.11/{account_id}/campaigns and after this defining the (time_range) parameter(s) for the insights of your campaign.

Related

Facebook Insights API not returning store visits data

I am trying to retrieve Store Visits data from the Facebook Insights API. Based on their documentation, these should be available by specifying the following parameters:
store_visit_actions
cost_per_store_visit_actions
When I use store_visit_actions as a parameter, no data is returned. I know data exists because it is displayed through their UI reporting tool.
When I use cost_per_store_visit_actions, I receive a 100 invalid param error:
cost_per_store_visit_actions is not valid for fields param.
These params are listed as "In Development", however, I'm retrieving other development parameters without issue. Is anyone facing the same issue or know how to fix?
this is because the metrics
store_visit_actions
cost_per_store_visit_actions
are deprecated in facebook api v11.0. You can checkout this link:
https://developers.facebook.com/docs/graph-api/changelog/version11.0/

An unknown error has occurred on Graph Facebook

I tried to get Data from Facebook Page with the graph of Facebook but I have a problem.
When I try to go on link like:
https://graph.facebook.com/ID-PAGE?access_token=MY_ACCESS_TOKEN
I always do this to have the Data from a Page but since today I have the error Message: "An unknown error has occurred".
Thanks for help.
EDIT:
The bug is fixed : https://developers.facebook.com/bugs/486654544831076/?search_id
Have a look at my answer at
How to get user email and birthday from Facebook API Version v2.4
You have to specify each field you want to query now with v2.4. If you want to explicitly use v2.3, you need to prepend your calls by /v2.3 like this:
/v2.3/{page_id}?access_token=MY_ACCESS_TOKEN
Seems like there's currently a bug regarding requests made with app access tokens instead of user access tokens:
https://developers.facebook.com/bugs/486654544831076/
At this moment, I pretty much figured out what is happening, and it looks like a bug in the Facebook API.
For v2.3 and lower:
The /PAGE-ID call will return an Unknown server error when you don't pass ?fields=username (for example). If you do pass the fields option, it will work. You can get it out of the docs.
For v2.4:
This will work, but you will miss a lot of data, so you'll also have to pass the fields options. But if you don't pass that, this version will give you back only the most basic of details. This is as described in the version release: https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
So the solution for now, would be to add the ?fields= everywhere you need, or to wait for Facebook to maybe ever solve it.
(And while you're at it, you might as well upgrade to v2.4 ;-)

Facebook Graph API version change - can't retrieve posts

Since Facebook's Graph API changed to version 2.4, I find that any query attempting to retrieve posts made returns an error:
type: OAuthException, code: 1, message: An unknown error has occurred. [HTTP 500]
My request code uses Facebook's koala ruby api to make requests:
posts = #graph.get_object(appid+"/posts?limit=20",api_version: "v2.3")
I added the version count now, based on koala's recommendation, but the result for this is still the same error that I got without specifying the version. My access token is definitely valid, does anyone know if something else has changed or if this is a bug?
Extending #Tobi 's comment. You have to pass a page/event/user/group id to retrieve the post.
Also, you've to explicitly pass fields parameter to query additional data of a post. So your query will become:
posts = #graph.get_object(id+"/posts?fields=id,name,message,picture&limit=20",api_version: "v2.4")
Please refer to this document of Facebook Developers to learn more about /postsedge.

Facebook graph api - Unsupported get request

I'm creating a custom module in Drupal, that for part of its functionality must fetch posts from a business page. So for simplicity, I'm using fbapp module as a dependency (drupal.org/project/fbapp), so that I can use it's authentication and request functions (fbapp_app_authenticate() and fbapp_graph_request()) without having to worry about the constant facebook graph updates making my own code obsolete.
I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"
Here's the queries and responses my code produces:
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials
array(1) {
["access_token"]=>
string(43) "<redacted>|<redacted>"
}
graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"
string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"
Can anyone verify a correct way to query a Facebook page programmatically, perhaps there's a setting in the page I'm querying that I need to set (although I can't find anything)?
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):
See
https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms
It looks like everything you have done is correct. The response you got can be (i am not sure) because you got your clients pageid wrong.

"call_to_action_type field in creative is required in this ad" returned while creating ads using marketing api

When I use adcreatives endpoint with object_story_spec parameter to create ads or using object_story_id parameter following instructions in this link :
I got this error message:
{"error":{"message":"Invalid
parameter","type":"FacebookApiException","code":100,"error_subcode":1487664,"is_transient":false,"error_user_title":"Missing
Call To Action Type","error_user_msg":"call_to_action_type field in
creative is required in this ad"}}
Anyone knows how to solve this problem?
Are you not setting the call_to_action field? While it's not explicitly stated in the docs (as far as I can see) the field is mentioned for all ads for mobile app install or engagement campaigns so I suggest setting it.
https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.2#cta_definitions