@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | private $batchSize; |
| 14 | 14 | private $account; |
| 15 | 15 | |
| 16 | - public function __construct(Account $account=null, $batchSize=10, $batch=[]) |
|
| 16 | + public function __construct(Account $account = null, $batchSize = 10, $batch = []) |
|
| 17 | 17 | { |
| 18 | 18 | parent::__construct($account); |
| 19 | 19 | $this->account = $account; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @throws BatchLimitExceeded when the batch is full |
| 70 | 70 | * @return $batch|$this->batch |
| 71 | 71 | */ |
| 72 | - public function assureBatchSize($batch=null) |
|
| 72 | + public function assureBatchSize($batch = null) |
|
| 73 | 73 | { |
| 74 | 74 | if (count($batch ?: $this->batch) < $this->batchSize) { |
| 75 | 75 | return $batch ?: $this->batch; |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | const RESOURCE = 'tailored_audience_memberships'; |
| 19 | 19 | const OPERATION = 'Update'; |
| 20 | 20 | |
| 21 | - public function __construct(Account $account=null, $members=[]) |
|
| 21 | + public function __construct(Account $account = null, $members = []) |
|
| 22 | 22 | { |
| 23 | 23 | parent::__construct($account, self::MAX_BATCH_SIZE, $members); |
| 24 | 24 | } |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | |
| 88 | 88 | public function setAudienceNames(array $names) |
| 89 | 89 | { |
| 90 | - $this->audience_names = explode(', ', $names); |
|
| 90 | + $this->audience_names = explode(', ', $names); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function getEffectiveAt() |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Hborras\TwitterAdsSDK\TwitterAds; |
| 4 | 4 | use Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience\TailoredAudienceMemberships; |
| 5 | -use Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience\TailoredAudienceMember;; |
|
| 5 | +use Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience\TailoredAudienceMember; ; |
|
| 6 | 6 | |
| 7 | 7 | require '../autoload.php'; |
| 8 | 8 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $twitterAds = new TwitterAds(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); |
| 17 | 17 | |
| 18 | 18 | /** If the file is too large, I highly recommend increase the timeout */ |
| 19 | -$twitterAds->setTimeouts(5,45); |
|
| 19 | +$twitterAds->setTimeouts(5, 45); |
|
| 20 | 20 | |
| 21 | 21 | // Retrieve account information |
| 22 | 22 | $account = $twitterAds->getAccounts(ACCOUNT_ID); |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | /** If the file is not hashed line by line, you need to hash it, for example for emails is this code*/ |
| 25 | 25 | |
| 26 | 26 | $file = fopen("path/to/list.txt", "r"); |
| 27 | -$newFile = fopen('path/to/new_list.txt','w'); |
|
| 28 | -while(!feof($file)){ |
|
| 27 | +$newFile = fopen('path/to/new_list.txt', 'w'); |
|
| 28 | +while (!feof($file)) { |
|
| 29 | 29 | $line = fgets($file); |
| 30 | 30 | $normalized_email = strtolower(trim($line, " \t\r\n\0\x0B.")); |
| 31 | 31 | $normalized_email = hash('sha256', $normalized_email); |
| 32 | - fwrite($newFile,$normalized_email."\n"); |
|
| 32 | + fwrite($newFile, $normalized_email."\n"); |
|
| 33 | 33 | # do same stuff with the $line |
| 34 | 34 | } |
| 35 | 35 | fclose($newFile); |
| 36 | 36 | fclose($file); |
| 37 | 37 | $audience = new TailoredAudience($account); |
| 38 | -$audience->create('path/to/new_list.txt','Test List', TailoredAudience::LIST_TYPE_EMAIL); |
|
| 38 | +$audience->create('path/to/new_list.txt', 'Test List', TailoredAudience::LIST_TYPE_EMAIL); |
|
| 39 | 39 | |
| 40 | 40 | /** @var TwitterAds\TailoredAudience\TailoredAudienceChanges $status */ |
| 41 | 41 | $status = $audience->status(); |
@@ -55,9 +55,9 @@ |
||
| 55 | 55 | $defaults['oauth_token'] = $token->key; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if(isset($parameters['raw'])){ |
|
| 58 | + if (isset($parameters['raw'])) { |
|
| 59 | 59 | $parameters = array_merge($defaults, ['oauth_body_hash' => base64_encode(sha1($parameters['raw'], TRUE))]); |
| 60 | - } else if(empty($parameters)){ |
|
| 60 | + } else if (empty($parameters)) { |
|
| 61 | 61 | $parameters = array_merge($defaults, ['oauth_body_hash' => base64_encode(sha1('', TRUE))]); |
| 62 | 62 | } else { |
| 63 | 63 | $parameters = array_merge($defaults, $parameters); |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | $resource = str_replace(Resource::RESOURCE_REPLACE, $account->getId(), self::TWEET_CREATE); |
| 61 | 61 | try { |
| 62 | 62 | $response = $account->getTwitterAds()->post($resource, $params); |
| 63 | - } catch( \Exception $e) { |
|
| 63 | + } catch (\Exception $e) { |
|
| 64 | 64 | print_r($e->getErrors()); |
| 65 | 65 | } |
| 66 | 66 | die(); |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function save() |
| 59 | 59 | { |
| 60 | - if(!$this->getId()){ |
|
| 60 | + if (!$this->getId()) { |
|
| 61 | 61 | $resource = str_replace(static::RESOURCE_REPLACE, $this->getAccount()->getId(), static::RESOURCE); |
| 62 | 62 | $resource = str_replace(self::RESOURCE_TAILORED_AUDIENCE_ID_REPLACE, $this->getTailoredAudienceId(), $resource); |
| 63 | 63 | $response = $this->getAccount()->getTwitterAds()->post($resource, []); |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | $this->createAudience($name, $listType); |
| 69 | 69 | $location = $upload->perform(); |
| 70 | 70 | $tailoredAudienceChange = new TailoredAudienceChanges($this->getAccount()); |
| 71 | - $tailoredAudienceChange->updateAudience($this->getId(),$location, $listType, TailoredAudienceChanges::ADD); |
|
| 71 | + $tailoredAudienceChange->updateAudience($this->getId(), $location, $listType, TailoredAudienceChanges::ADD); |
|
| 72 | 72 | |
| 73 | 73 | return $this->reload(); |
| 74 | 74 | } |