Comments (13)
This is not an issue with the SDK so I'm going to close it out. You need to go to audiences in ads manager to accept the Custom Audiences terms. There is also a field within the account capabilities that indicates whether it has been accepted.
https://www.facebook.com/ads/manage/audiences.php
To create audience of people who visit your website, you'll want to use a Website Custom Audience, see this CURL example to capture all people who visit a site with a pixel on it:
https://developers.facebook.com/docs/reference/ads-api/custom-audience-website/v2.2#create
from facebook-php-business-sdk.
Hi @paulbain,
It's not an issue with the SDK, its more of an issue with the API.
I went to the web interface, created an audience, accepted the terms. My code still throws the exception:
(#2655) Terms of service has not been accepted
Would you be able to provide an example of the SDK performing the call to create a Website Custom Audience?
I appreciate all the help you have provided, and I know several of the things you are helping with are not directly SDK related.
from facebook-php-business-sdk.
is it accepted for the same adaccount you are using? it's per-adaccount and there is a dropdown menu at the top. I'm not sure if there is a separate one for website custom audiences. Try creating an audience in adsmanager to check for that also.
I'll put together an example later today if I can. You can also ask non-issue questions (how do I do X?) on StackOverflow as there is an active community of people helping there and the format is easier for these kinds of questions:
stackoverflow.com/questions/tagged/facebook-ads-api
from facebook-php-business-sdk.
When you create a Website Traffic Audience on facebook.com it does not ask for you to agree to the terms. You need to create a Customer List Audience, then you need to add 20 email addresses. Once this is saved I was able to add audiences using the API.
from facebook-php-business-sdk.
The code to add the audience was:
use \FacebookAds\Api;
use \FacebookAds\Object\CustomAudience;
use \FacebookAds\Object\Fields\CustomAudienceFields;
Api::init($app_id, $app_secret, $access_token);
$audience = new CustomAudience(null, $account_id);
$audience->setData(array(
CustomAudienceFields::NAME => 'website test',
CustomAudienceFields::DESCRIPTION => 'website test',
CustomAudienceFields::SUBTYPE => 'WEBSITE',
CustomAudienceFields::RETENTION_DAYS => '30',
CustomAudienceFields::RULE => array('url' => array('contains' => '/foobar')),
));
$audience->create();
Would be great to see this in the examples.
from facebook-php-business-sdk.
The code to use the audience in an AdSet was:
use \FacebookAds\Api;
use \FacebookAds\Object\AdSet;
use \FacebookAds\Object\Fields\AdSetFields;
use \FacebookAds\Object\CustomAudience;
use \FacebookAds\Object\Fields\CustomAudienceFields;
Api::init($app_id, $app_secret, $access_token);
$audience = new CustomAudience(null, $account_id);
$audience->setData(array(
CustomAudienceFields::NAME => 'website test',
CustomAudienceFields::DESCRIPTION => 'website test',
CustomAudienceFields::SUBTYPE => 'WEBSITE',
CustomAudienceFields::RETENTION_DAYS => '30',
CustomAudienceFields::RULE => array('url' => array('contains' => '/foobar')),
));
$audience->create();
$targeting = array(
'custom_audiences' => array(
array(
'id' => $audience->{CustomAudienceFields::ID},
'name' => $audience->{CustomAudienceFields::NAME},
)
)
);
// create adSet
$adSet = new AdSet(null, $account_id);
$adSet->setData(array(
AdSetFields::NAME => 'My Ad',
AdSetFields::CAMPAIGN_GROUP_ID => 1234567890, // replace with campaign id
AdSetFields::CAMPAIGN_STATUS => AdSet::STATUS_ACTIVE,
AdSetFields::DAILY_BUDGET => '100',
AdSetFields::BID_TYPE => 'CPC',
AdSetFields::BID_INFO => array('CLICKS' => 30),
AdSetFields::TARGETING => $targeting,
));
$adSet->create();
from facebook-php-business-sdk.
Sorry, that didnt work...
[error] => Array (
[message] => An unknown error has occurred.
[type] => OAuthException
[code] => 1
)
Error occurs on the line $adSet->create();
. Do I need to give more permissions?
from facebook-php-business-sdk.
Nevermind the last message, the code does work. I messed up the targeting array when testing.
from facebook-php-business-sdk.
I am using laravel 5.4
On executing the code to create audiences I am getting the following error.
PHP Fatal error: Uncaught FacebookAds\Http\Exception\AuthorizationException: (#2663) Terms of service has not been accepted. To accept, go to https://www.facebook.com/customaudiences/app/tos/?act=105142470269795 in /Users/williammukesh/facebook-php-ads-sdk/src/FacebookAds/Http/Exception/RequestException.php:144
After hitting:https://www.facebook.com/customaudiences/app/tos/?act=105142470269795
but the below url shows I have accepted TOS.
https://www.facebook.com/customaudiences/app/tos/
from facebook-php-business-sdk.
Plz tell me If you guys have any idea to fix this issue.
from facebook-php-business-sdk.
I'm having the same issue with nodejs sdk even now.
from facebook-php-business-sdk.
If you are using a sandbox, you need to follow these steps (grabbed from this StackOverflow answer: https://stackoverflow.com/a/42766604/544130):
"To accept custom audiences ToS go to the application management -> Marketing API -> Tools -> Sandbox Ad Account Management -> Actions -> Accept TOS"
from facebook-php-business-sdk.
@Taytay I have already Accept TOS like the step you describe but I still facing error when using sandbox. Do you solve the problem?
{
"error": {
"message": "Permissions error",
"type": "OAuthException",
"code": 200,
"error_subcode": 1870034,
"is_transient": false,
"error_user_title": "Custom Audience Terms Not Accepted",
"error_user_msg": "You'll need to agree to the Custom Audience terms before you can create or edit an audience of CUSTOM type. To accept, go to https://www.facebook.com/ads/manage/customaudiences/tos/?act=313575366050779.",
"fbtrace_id": "CQhFmQpzyoS"
}
}
from facebook-php-business-sdk.
Related Issues (20)
- getDefaultRequestHeaders() is misspelled as getDefaultRequestHeaderds() HOT 1
- PHP 8.1 Deprecation HOT 4
- syntax error, unexpected '|', expecting ';' or '{' HOT 4
- Union types are only allowed since php8 HOT 2
- Exception: field 'id' is required Error HOT 2
- شخص ما أخترق حسابي الشخصي
- Normalizer.php strlen() must be of type string Problem
- Facebook Multi-Language Ads
- Syntax error in FB version v16.0.0 HOT 1
- The AdAccountFields enum does not currently implement the ACCOUNT_STATUS field. HOT 1
- Exception thrown without a stack frame in Unknown on line 0 HOT 1
- How to create a AAA advertisements above version 17
- Fix package installation instructions in README file
- Fff HOT 1
- error
- ad creative Url Tracking Params Update HOT 1
- OpenSSL SSL_connect: Connection reset by peer in connection to graph.facebook.com:443 Error
- Static singletons used everywhere HOT 3
- Incorrect PHPDoc types HOT 2
- Not able to access Business User Insights for multiple users using the Instagram API.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facebook-php-business-sdk.