Exemplo n.º 1
0
 /**
  * Returns a collection of targeting criteria available to the
  * current line item.
  *
  * @param string $id
  * @param array $params
  *
  * @return Cursor | Resource
  *
  * @throws TwitterAdsException
  */
 public function getTargetingCriteria($id = '', $params = [])
 {
     $targetingCriteria = new TargetingCriteria();
     $targetingCriteria->setAccount($this->getAccount());
     $this->validateLoaded();
     if ($id == '') {
         $cursor = $targetingCriteria->line_item_all($this->getId(), $params);
     } else {
         $cursor = $targetingCriteria->load($id, $params);
     }
     return $cursor;
 }
Exemplo n.º 2
0
const ACCESS_TOKEN = 'your access token';
const ACCESS_TOKEN_SECRET = 'your access token secret';
const ACCOUNT_ID = 'account id';
// Create twitter ads client
$twitterAds = new TwitterAds(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
// Retrieve account information
$account = $twitterAds->getAccounts(ACCOUNT_ID);
// Create your campaign
$campaign = new Campaign($account);
$campaign->setFundingInstrumentId($account->getFundingInstruments()->first()->getId());
$campaign->setDailyBudgetAmountLocalMicro(1000000);
$campaign->setName("My first campaign: ");
$campaign->setPaused(false);
$campaign->setStartTime(new \DateTime());
$campaign->save();
// Create a line item for the campaign
$lineItem = new LineItem($account);
$lineItem->setCampaignId($campaign->getId());
$lineItem->setName("My first line item: ");
$lineItem->setProductType(Enumerations::PRODUCT_PROMOTED_TWEETS);
$lineItem->setPlacements([Enumerations::PLACEMENT_ALL_ON_TWITTER]);
$lineItem->setObjective(Enumerations::OBJECTIVE_TWEET_ENGAGEMENTS);
$lineItem->setBidAmountLocalMicro(10000);
$lineItem->setPaused(false);
$lineItem->save();
// Add targeting criteria
$targetingCriteria = new TargetingCriteria($account);
$targetingCriteria->setLineItemId($lineItem->getId());
$targetingCriteria->setTargetingType('LOCATION');
$targetingCriteria->setTargetingValue('00a8b25e420adc94');
$targetingCriteria->save();
Exemplo n.º 3
0
 /**
  * @depends testGetTargetingCriterias
  * @param Cursor $targetingCriterias
  * @return TargetingCriteria
  */
 public function testGetTargetingCriteria($targetingCriterias)
 {
     /** @var TargetingCriteria $firstTargetingCriteria */
     $firstTargetingCriteria = $targetingCriterias->next();
     $targetingCriteria = new TargetingCriteria();
     $targetingCriteria->setAccount($firstTargetingCriteria->getAccount());
     $targetingCriteria->load($firstTargetingCriteria->getId());
     $this->assertEquals($targetingCriteria->getId(), $firstTargetingCriteria->getId());
     return $targetingCriteria;
 }