Giter Site home page Giter Site logo

Comments (13)

paulbain avatar paulbain commented on April 25, 2024

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.

cornernote avatar cornernote commented on April 25, 2024

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.

paulbain avatar paulbain commented on April 25, 2024

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.

cornernote avatar cornernote commented on April 25, 2024

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.

cornernote avatar cornernote commented on April 25, 2024

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.

cornernote avatar cornernote commented on April 25, 2024

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.

cornernote avatar cornernote commented on April 25, 2024

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.

cornernote avatar cornernote commented on April 25, 2024

Nevermind the last message, the code does work. I messed up the targeting array when testing.

from facebook-php-business-sdk.

IAmMukeshKumar avatar IAmMukeshKumar commented on April 25, 2024

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
screen shot 2017-11-26 at 3 41 50 pm

but the below url shows I have accepted TOS.
https://www.facebook.com/customaudiences/app/tos/

from facebook-php-business-sdk.

IAmMukeshKumar avatar IAmMukeshKumar commented on April 25, 2024

Plz tell me If you guys have any idea to fix this issue.

from facebook-php-business-sdk.

bevinhex avatar bevinhex commented on April 25, 2024

I'm having the same issue with nodejs sdk even now.

from facebook-php-business-sdk.

Taytay avatar Taytay commented on April 25, 2024

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.

sonhgc00016 avatar sonhgc00016 commented on April 25, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.