/**
  * AdsPixels can be created but only one per account can exist
  */
 public function testCreate()
 {
     $pixel = new AdsPixel(null, $this->getActId());
     $has_thrown = false;
     try {
         $pixel->create();
     } catch (\Exception $e) {
         $has_thrown = true;
     }
     $this->assertTrue($has_thrown);
 }
// _DOC open [CUSTOM_AUDIENCE_USERS_ADD_ID]
// _DOC vars [custom_audience_id:s, application_id, user_id_1, user_id_2]
// use FacebookAds\Object\CustomAudience;
// use FacebookAds\Object\Fields\CustomAudienceFields;
// use FacebookAds\Object\Values\CustomAudienceTypes;
// Add Facebook IDs of users of certain applications
$audience = new CustomAudience($custom_audience_id);
$audience->addUsers(array($user_id_1, $user_id_2), CustomAudienceTypes::ID, array($application_id));
// _DOC close [CUSTOM_AUDIENCE_USERS_ADD_ID]
$audience->delete();
$account = new AdAccount($ad_account_id);
$pixels = $account->getAdsPixels(array(AdsPixelsFields::CODE));
if (!$pixels->count()) {
    $pixel = new AdsPixel(null, $ad_account_id);
    $pixel->{AdsPixelsFields::NAME} = 'My WCA Pixel';
    $pixel->create();
} else {
    $pixel = $pixels->current();
}
$pixel_id = $pixel->{AdsPixelsFields::ID};
// _DOC open [CUSTOM_AUDIENCE_CREATE_WCA]
// _DOC vars [ad_account_id:s, pixel_id]
// use FacebookAds\Object\CustomAudience;
// use FacebookAds\Object\Fields\CustomAudienceFields;
// use FacebookAds\Object\Values\CustomAudienceSubtypes;
$custom_audience = new CustomAudience(null, $ad_account_id);
$custom_audience->setData(array(CustomAudienceFields::PIXEL_ID => $pixel_id, CustomAudienceFields::NAME => 'My New Website Custom Audience', CustomAudienceFields::SUBTYPE => CustomAudienceSubtypes::WEBSITE, CustomAudienceFields::RETENTION_DAYS => 15, CustomAudienceFields::RULE => array('url' => array('i_contains' => 'shoes')), CustomAudienceFields::PREFILL => true));
$custom_audience->create();
// _DOC close [CUSTOM_AUDIENCE_CREATE_WCA]
$custom_audience_id = $custom_audience->{CustomAudienceFields::ID};
// _DOC open [CUSTOM_AUDIENCE_READ]