New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error when creating custom audience #43
Comments
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. 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: |
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. |
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: |
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. |
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. |
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(); |
Sorry, that didnt work...
Error occurs on the line |
Nevermind the last message, the code does work. I messed up the targeting array when testing. |
I am using laravel 5.4 After hitting:https://www.facebook.com/customaudiences/app/tos/?act=105142470269795 but the below url shows I have accepted TOS. |
Plz tell me If you guys have any idea to fix this issue. |
I'm having the same issue with nodejs sdk even now. |
If you are using a sandbox, you need to follow these steps (grabbed from this StackOverflow answer: https://stackoverflow.com/a/42766604/544130): |
@Taytay I have already Accept TOS like the step you describe but I still facing error when using sandbox. Do you solve the problem?
|
The code:
The error:
I have 2 questions:
https://developers.facebook.com/docs/reference/ads-api/custom-audience-targeting/#data_source
The text was updated successfully, but these errors were encountered: