During the creation of an AdCreative in the facebook marketing api (using the PHP sdk), I get the "Invalid Parameter" error. According to the graph-api (see below), the error is happening because I am trying to create an AdCreative using an app that is in development mode.
Since I am making a Proof of Concept, I doubt that my app will be approved for the ads_management permission (which I need for the creation of an AdCreative).
Is there a way to create the AdCreative (and consequently an Ad) using the facebook-marketing-api using my app (in development mode)?
if not, is there any other way to do so?
When I put the application in "public" mode, I get the following error:
{"error":{"message":"(#294) Managing advertisements requires an access token with the extended permission for ads_management","type":"OAuthException","code":294,"fbtrace_id":"AHZ4vUXzCv+"}}
I am using the official Creative guide by facebook to create the AdCreative: https://developers.facebook.com/docs/marketing-api/buying-api
I am currently using the following code to create the AdCreative
// campaign creation (objective -> reach)
// adset creation
// adimage creation
$creativeFields = [];
$creativeParams = [
'name' => $validatedRequest['creative_name'],
'object_story_spec' => [
'page_id' => $page_id,
'link_data' => [
'image_hash' => $image->{AdImageFields::HASH},
'link' => "https://facebook.com/{$page_id}",
'message' => 'THIS IS THE DEFAULT MESSAGE FOR AD CREATIVES - [[THIS IS VERSION 2]]',
],
],
];
$creativeId = (new AdAccount($id))->createAdCreative($creativeFields, $creativeParams)
->exportAllData();
When I try to create the AdCreative using the graph-api (using curl) I get the following JSON response:
{"error":{"message":"Invalid Parameter", "type":"OAuthException", "code":100, "error_subcode":1885183, "is_transient":false, "error_user_title":"Ads creative post was created by an app that is in development mode", "error_user_msg":"Ads creative post was created by an app that is in development mode. It must be in public to create this ad.", "fbtrace_id":"GzpSaGkDlNa"}}
Related
currently all bots developed by me (including several production bots which have been in use for a while) stopped replying to messages. According to logs, Messenger is returning the following response:
(
[error] => Array
(
[message] => An active access token must be used to query information about the current user.
[type] => OAuthException
[code] => 2500
[fbtrace_id] => C9ExJBwjvfp
)
)
This is deeply frusturating, because the bots have been working well and the issue appeared in deployed bots which have been working independently for a while.
The request is as follows:
(
[recipient] => Array
(
[id] => 1783672501695199
)
[message] => Array
(
[text] => MESSAGE_TEXT
)
[tag] =>
[notification_type] => REGULAR
[messaging_type] => RESPONSE
[access_token] => XXXXXXXX
)
Is there a known bug or a backwards incompatible change in API? Had anyone encountered this issue?
This usually happens when the user who authorised a Facebook Page for given Facebook App revokes the token. This is generally possible from Facebook settings page (see Apps or Business Integrations).
You can fix it by re-authorisation of your Page in developer's portal (select your Facebook App, navigate to Settings and scroll to "Token Generation" section). If you don't have the Facebook App than you have to do it in the app of your bot provider.
Notice that there is an ongoing procedure of all Facebook App required to be approved again. But the final deadline is the 1st of August. So this should not be the case.
For me the problem was the PHP library I was using that sent the data to FB API by encoding with query string. As soon as I changed that with json_encode the problem was fixed. Hope that helps anyone.
It was actually a bug and it was fixed
$fb = new \Facebook\Facebook([
'app_id' => config('config.fb_app_id'),
'app_secret' => config('config.fb_app_secret'),
'default_graph_version' => 'v3.0',
]);
// User info
$fb->setDefaultAccessToken($access_token);
$request = $fb->request('GET', '/me?fields=id,name');
$response = $fb->getClient()->sendRequest($request)->getDecodedBody();
The above code doesn't work and it says "Unsupported get request. Object with ID 'me' does not exist".
Really strange!! This was working fine few days back and suddenly it started throwing Errors. Whats wrong with this code?
Had the same problem.
Didn't notice facebook app was in developer mode.
Was working for me because I was configured as an admin in the app.
You need to add testers for the app
We had the same problem using the python SDK since yesterday on all accounts using permanent tokens.
We solved it now by creating new tokens in the facebook business manager. Maybe this readme also provides some guidance https://github.com/mara/facebook-ads-performance-downloader
There can be multiple reasons for it, you should visit your App's Alerts page first to check if there is some issue with your account:
https://developers.facebook.com/apps/<APP_ID>/alerts/inbox/?business_id=<BUSINESS_ID>
You cannot access live data if your application is in development mode.
The Alerts look like this:
hi I use facebook application and I want send feed message to page wall
$accesstokens = 'blalbalba';
$post = array(
'access_token' => $accesstokens,
'message' => 'This message auto created - ' . date('d/m/Y H:i:s')
);
I try everythin from , to ,user
I try graph api explorer
when I try send message with token
facebook api add extra this code to message
"application": {
"name": "Application name",
"namespace": "application_namespace",
"id": "app id"
},
but I try send message normally from facebook and this code not in there
only adding this code try facebook api
and I see the application name on wall message "Share by Application"
How I change this ? I create page and when I try send message with facebook api and I sending message but I dont want see application name on my page wall
Like CBroe says in his comment, you are not allowed to auto-post any content, or use pre-filled comments/messages/captions. This is explained in Facebook's policy
There is also no way to remove app attribution data when creating content from an app. This is regardless of what SDK you are using. Even if you don't use an SDK, but only the Graph API, your content will contain app attribution data.
I have Phonegap's Facebook plugin working perfectly within my Android app. This plugin uses Facebook's client-side Javascript flow. However, I would like to upload photos to FB from the server-side, instead of client-side, as this is much (much) more efficient.
Is it possible to use Facebook's access token generated from client-side on the server-side? (BTW, I have Facebook's PHP SDK working perfectly on stand alone web pages.)
I am getting a "(#200) Permissions Error" trying to pull this off.
If the client-side token cannot be used on the server, any other suggestions? I do not know of a way to generate a server-side Facebook token from a Phonegap app.
Edit:
It appears that you actually can use a client side Facebook token on the server. It's simple matter of upgrading to the latest Facebook PHP SDK, and using the $facebook->setAccessToken() function with a token sent from Javascript.
An access token is valid via client or server. On facebook end it is the same thing: a request through HTTP.
If you are not able to upload photos, check that you have the appropriate user permissions for your application.
If you are trying to figure out what graph api calls you need, a good starting place is the javascript console:
https://developers.facebook.com/tools/console/
Here you can see in the javascript what calls are being made in order to read fromt he api, or make a feed story or upload. You will use the same graph URLS and variables using server side code.
Yes you can use client side token in server side.Actually when user is logged into facebook ,fb create an access token in cookies ,which you can access on both client as well as server and when user is logged out ,cookie is destroyed and access token becomes invalid.
And to upload the photos to facebook i used following code :
// $friends is an array of friend id to be tagged in photo
// $x and $y are the position of tags.
for($i=0;$i<sizeof($friends);$i++)
{
$tags[] = array(
'tag_uid'=>$friends[$i],
'x' => $x[$i],
'y' => $y[$i],
);
}
$photo_details = array(
'access_token'=>$access_token ,
'message'=> 'Any message',
'tags' => $tags
);
$file=$photo_name; //Example image file
$photo_details['image'] = '#' . realpath($file);
$upload_photo = $facebook->api('/me/photos', 'post', $photo_details);
I was wondering if it is possible to change your site url or canvas url using the graph api. I have admin rights to my application and I can change it via the gui but I would prefer to be changing it via a curl.
Thanks
Here is example:
$properties = array(
"callback_url" => '',
"installable" => 1,
"profile_tab_url" => "",
"tab_default_name" => "",
'tos_url' => '',
'privacy_url' => ''
);
$facebook = new Facebook(array('appId'=>'YOUR_APP_ID','secret' = > '..', ...));
$facebook->api(array(
'method'=>'admin_setAppProperties',
'properties'=>json_encode($properties))
);
Here is a list of the properties you can set: http://developers.facebook.com/docs/appproperties/
There is also admin.getAppProperties more info you can find here: http://developers.facebook.com/docs/reference/rest/admin.getAppProperties/
Using Facebook SDK
You need to use the old REST method admin.SetAppProperties
https://developers.facebook.com/docs/reference/rest/admin.setAppProperties/
At the moment FB has not yet moved that method yet to the OpenGraph but you can still call REST methods via the Graph API (As shown in the console in the page above).
Even then you cannot change the secure_canvas and secure_tab url setting. FB is apparently working on make those settings as part of the API as far as I heard.
You can now change app properties via Graph API. You can make POST request, using the application id in the path, and use the app access token as the access token, and pass in key/value pairs as POST variables for properties you'd like to modify.
https://developers.facebook.com/docs/reference/api/application/ has a list of the application properties that you can modify with the Graph API.