@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | * @param string $class The fully-qualified class name. |
7 | 7 | * @return void |
8 | 8 | */ |
9 | -spl_autoload_register(function ($class) { |
|
9 | +spl_autoload_register(function($class) { |
|
10 | 10 | |
11 | 11 | // project-specific namespace prefix |
12 | 12 | $prefix = 'Hborras\\TwitterAdsSDK\\'; |
13 | 13 | |
14 | 14 | // base directory for the namespace prefix |
15 | - $base_dir = __DIR__ . '/src/'; |
|
15 | + $base_dir = __DIR__.'/src/'; |
|
16 | 16 | |
17 | 17 | // does the class use the namespace prefix? |
18 | 18 | $len = strlen($prefix); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | // replace the namespace prefix with the base directory, replace namespace |
28 | 28 | // separators with directory separators in the relative class name, append |
29 | 29 | // with .php |
30 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
30 | + $file = $base_dir.str_replace('\\', '/', $relative_class).'.php'; |
|
31 | 31 | |
32 | 32 | // if the file exists, require it |
33 | 33 | if (file_exists($file)) { |
@@ -81,22 +81,22 @@ discard block |
||
81 | 81 | { |
82 | 82 | /** Here you can add any header you want to the request*/ |
83 | 83 | $headers = [ |
84 | - 'x-ton-expires: ' . gmdate('D, d M Y H:i:s T', strtotime("+10 day")), |
|
85 | - 'content-type: ' . $this->getContentType(), |
|
86 | - 'Content-Length: ' . $this->fileSize |
|
84 | + 'x-ton-expires: '.gmdate('D, d M Y H:i:s T', strtotime("+10 day")), |
|
85 | + 'content-type: '.$this->getContentType(), |
|
86 | + 'Content-Length: '.$this->fileSize |
|
87 | 87 | ]; |
88 | 88 | |
89 | - $response = $this->getTwitterAds()->post(self::DEFAULT_DOMAIN . self::DEFAULT_RESOURCE . self::DEFAULT_BUCKET, ['raw' => file_get_contents($this->filePath)], $headers); |
|
89 | + $response = $this->getTwitterAds()->post(self::DEFAULT_DOMAIN.self::DEFAULT_RESOURCE.self::DEFAULT_BUCKET, ['raw' => file_get_contents($this->filePath)], $headers); |
|
90 | 90 | return $response; |
91 | 91 | } |
92 | 92 | |
93 | 93 | public function uploadChunk($resource, $chunkSize, $bytes, $bytesStart, $bytesRead) |
94 | 94 | { |
95 | 95 | $headers = [ |
96 | - 'Content-Type: ' . $this->getContentType(), |
|
97 | - 'Content-Range: bytes ' . $bytesStart . '-' . ($bytesRead - 1) . '/' . $this->fileSize |
|
96 | + 'Content-Type: '.$this->getContentType(), |
|
97 | + 'Content-Range: bytes '.$bytesStart.'-'.($bytesRead - 1).'/'.$this->fileSize |
|
98 | 98 | ]; |
99 | - $response = $this->getTwitterAds()->put(self::DEFAULT_DOMAIN . $resource, ['raw' => $bytes], $headers); |
|
99 | + $response = $this->getTwitterAds()->put(self::DEFAULT_DOMAIN.$resource, ['raw' => $bytes], $headers); |
|
100 | 100 | |
101 | 101 | return $response; |
102 | 102 | } |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | public function initChunkedUpload() |
105 | 105 | { |
106 | 106 | $headers = [ |
107 | - 'X-Ton-Content-Type: ' . $this->getContentType(), |
|
108 | - 'X-Ton-Content-Length: ' . $this->fileSize, |
|
109 | - 'X-Ton-Expires: ' . gmdate('D, d M Y H:i:s T', strtotime("+6 day")), |
|
110 | - 'Content-Type: ' . $this->getContentType(), |
|
111 | - 'Content-Length: ' . strval(0) |
|
107 | + 'X-Ton-Content-Type: '.$this->getContentType(), |
|
108 | + 'X-Ton-Content-Length: '.$this->fileSize, |
|
109 | + 'X-Ton-Expires: '.gmdate('D, d M Y H:i:s T', strtotime("+6 day")), |
|
110 | + 'Content-Type: '.$this->getContentType(), |
|
111 | + 'Content-Length: '.strval(0) |
|
112 | 112 | ]; |
113 | 113 | |
114 | - $resource = self::DEFAULT_DOMAIN . self::DEFAULT_RESOURCE . self::DEFAULT_BUCKET . '?resumable=true'; |
|
114 | + $resource = self::DEFAULT_DOMAIN.self::DEFAULT_RESOURCE.self::DEFAULT_BUCKET.'?resumable=true'; |
|
115 | 115 | $response = $this->getTwitterAds()->post($resource, [], $headers); |
116 | 116 | return $response; |
117 | 117 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | $output = ''; |
18 | 18 | if (is_array($input)) { |
19 | - $output = array_map([__NAMESPACE__ . '\Util', 'urlencodeRfc3986'], $input); |
|
19 | + $output = array_map([__NAMESPACE__.'\Util', 'urlencodeRfc3986'], $input); |
|
20 | 20 | } elseif (is_scalar($input)) { |
21 | 21 | $output = rawurlencode($input); |
22 | 22 | } |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | // June 12th, 2010 - changed to sort because of issue 164 by hidetaka |
105 | 105 | sort($value, SORT_STRING); |
106 | 106 | foreach ($value as $duplicateValue) { |
107 | - $pairs[] = $parameter . '=' . $duplicateValue; |
|
107 | + $pairs[] = $parameter.'='.$duplicateValue; |
|
108 | 108 | } |
109 | 109 | } else { |
110 | - $pairs[] = $parameter . '=' . $value; |
|
110 | + $pairs[] = $parameter.'='.$value; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61) |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function setTimeouts($connectionTimeout, $timeout) |
36 | 36 | { |
37 | - $this->connectionTimeout = (int)$connectionTimeout; |
|
38 | - $this->timeout = (int)$timeout; |
|
37 | + $this->connectionTimeout = (int) $connectionTimeout; |
|
38 | + $this->timeout = (int) $timeout; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function setDecodeJsonAsArray($value) |
45 | 45 | { |
46 | - $this->decodeJsonAsArray = (bool)$value; |
|
46 | + $this->decodeJsonAsArray = (bool) $value; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function setUserAgent($userAgent) |
53 | 53 | { |
54 | - $this->userAgent = (string)$userAgent; |
|
54 | + $this->userAgent = (string) $userAgent; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -37,7 +37,7 @@ |
||
37 | 37 | { |
38 | 38 | $endTime = isset($params[AnalyticsFields::END_TIME]) ? $params[AnalyticsFields::END_TIME] : new \DateTime('now'); |
39 | 39 | $endTime->setTime($endTime->format('H'), 0, 0); |
40 | - $startTime = isset($params[AnalyticsFields::START_TIME]) ? $params[AnalyticsFields::START_TIME] : new \DateTime($endTime->format('c') . " - 7 days"); |
|
40 | + $startTime = isset($params[AnalyticsFields::START_TIME]) ? $params[AnalyticsFields::START_TIME] : new \DateTime($endTime->format('c')." - 7 days"); |
|
41 | 41 | $startTime->setTime($startTime->format('H'), 0, 0); |
42 | 42 | $granularity = isset($params[AnalyticsFields::GRANULARITY]) ? $params[AnalyticsFields::GRANULARITY] : Enumerations::GRANULARITY_TOTAL; |
43 | 43 | $placement = isset($params[AnalyticsFields::PLACEMENT]) ? $params[AnalyticsFields::PLACEMENT] : Enumerations::PLACEMENT_ALL_ON_TWITTER; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $postData = $this->toPostdata(); |
179 | 179 | $out = $this->getNormalizedHttpUrl(); |
180 | 180 | if ($postData) { |
181 | - $out .= '?' . $postData; |
|
181 | + $out .= '?'.$postData; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $out; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | throw new TwitterOAuthException('Arrays not supported in headers'); |
214 | 214 | } |
215 | 215 | $out .= ($first) ? ' ' : ', '; |
216 | - $out .= Util::urlencodeRfc3986($k) . '="' . Util::urlencodeRfc3986($v) . '"'; |
|
216 | + $out .= Util::urlencodeRfc3986($k).'="'.Util::urlencodeRfc3986($v).'"'; |
|
217 | 217 | $first = false; |
218 | 218 | } |
219 | 219 | |
@@ -257,6 +257,6 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public static function generateNonce() |
259 | 259 | { |
260 | - return md5(microtime() . mt_rand()); |
|
260 | + return md5(microtime().mt_rand()); |
|
261 | 261 | } |
262 | 262 | } |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | $j = 1; |
38 | 38 | $l = 1; |
39 | 39 | foreach ($campaignsData as $campaign) { |
40 | - echo $i . ": " . $campaign->getId() . " " . $campaign->getName() . " " . $campaign->getStartTime()->format('Y-m-d') . " - " . $campaign->getEntityStatus() . PHP_EOL; |
|
40 | + echo $i.": ".$campaign->getId()." ".$campaign->getName()." ".$campaign->getStartTime()->format('Y-m-d')." - ".$campaign->getEntityStatus().PHP_EOL; |
|
41 | 41 | $lineItems = $campaign->getLineItems([TwitterAds\Fields\LineItemFields::COUNT => 2]); |
42 | 42 | /** @var LineItem $lineItem */ |
43 | 43 | foreach ($lineItems as $lineItem) { |
44 | - echo "\t" . $j . ": " . $lineItem->getId() . " " . $lineItem->getName() . " " . PHP_EOL; |
|
45 | - echo "\t\tBid: " . ($lineItem->getBidAmountLocalMicro() / 1000000) . PHP_EOL; |
|
46 | - echo "\t\tObjective: " . $lineItem->getObjective() . PHP_EOL; |
|
47 | - echo "\t\tCharge By: " . $lineItem->getChargeBy() . PHP_EOL; |
|
48 | - echo "\t\tBid Unit: " . $lineItem->getBidUnit() . PHP_EOL; |
|
49 | - echo "\t\tOptimization: " . $lineItem->getOptimization() . PHP_EOL; |
|
50 | - echo "\t\tBid Type: " . $lineItem->getBidType() . PHP_EOL; |
|
44 | + echo "\t".$j.": ".$lineItem->getId()." ".$lineItem->getName()." ".PHP_EOL; |
|
45 | + echo "\t\tBid: ".($lineItem->getBidAmountLocalMicro() / 1000000).PHP_EOL; |
|
46 | + echo "\t\tObjective: ".$lineItem->getObjective().PHP_EOL; |
|
47 | + echo "\t\tCharge By: ".$lineItem->getChargeBy().PHP_EOL; |
|
48 | + echo "\t\tBid Unit: ".$lineItem->getBidUnit().PHP_EOL; |
|
49 | + echo "\t\tOptimization: ".$lineItem->getOptimization().PHP_EOL; |
|
50 | + echo "\t\tBid Type: ".$lineItem->getBidType().PHP_EOL; |
|
51 | 51 | $targetingCriterias = $lineItem->getTargetingCriteria(); |
52 | 52 | /** @var TwitterAds\Campaign\TargetingCriteria $targetingCriteria */ |
53 | 53 | foreach ($targetingCriterias as $targetingCriteria) { |
54 | - echo "\t\t" . $l . ": " . $targetingCriteria->getId() . " " . $targetingCriteria->getName() . " " . |
|
54 | + echo "\t\t".$l.": ".$targetingCriteria->getId()." ".$targetingCriteria->getName()." ". |
|
55 | 55 | |
56 | - $targetingCriteria->getTargetingType() . " " . $targetingCriteria->getTargetingValue() . PHP_EOL; |
|
56 | + $targetingCriteria->getTargetingType()." ".$targetingCriteria->getTargetingValue().PHP_EOL; |
|
57 | 57 | |
58 | 58 | $l++; |
59 | 59 | } |
@@ -77,26 +77,26 @@ discard block |
||
77 | 77 | AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER |
78 | 78 | ], $async |
79 | 79 | ); |
80 | - while($job->getStatus() == TwitterAds\Fields\JobFields::PROCESSING){ |
|
80 | + while ($job->getStatus() == TwitterAds\Fields\JobFields::PROCESSING) { |
|
81 | 81 | echo "Job is still processing. Waiting 5 more seconds".PHP_EOL; |
82 | 82 | $job->read(); |
83 | 83 | sleep(5); |
84 | 84 | } |
85 | 85 | |
86 | - if($job->getStatus() == TwitterAds\Fields\JobFields::SUCCESS){ |
|
86 | + if ($job->getStatus() == TwitterAds\Fields\JobFields::SUCCESS) { |
|
87 | 87 | $result = gzfile($job->getUrl()); |
88 | 88 | $result = implode("", $result); |
89 | 89 | $stats = json_decode($result)->data; |
90 | 90 | $stats = $stats[0]->id_data[0]->metrics; |
91 | 91 | if (!is_null($stats->billed_charge_local_micro)) { |
92 | - echo "\t\t\t Start: " . $date[0]->format('Y-m-d H:i:s') . PHP_EOL; |
|
93 | - echo "\t\t\t End: " . $date[1]->format('Y-m-d H:i:s') . PHP_EOL; |
|
94 | - echo "\t\t\t " . ($stats->billed_charge_local_micro[0] / 1000000) . "€" . PHP_EOL; |
|
92 | + echo "\t\t\t Start: ".$date[0]->format('Y-m-d H:i:s').PHP_EOL; |
|
93 | + echo "\t\t\t End: ".$date[1]->format('Y-m-d H:i:s').PHP_EOL; |
|
94 | + echo "\t\t\t ".($stats->billed_charge_local_micro[0] / 1000000)."€".PHP_EOL; |
|
95 | 95 | echo "\t\t\t\t App clicks: "; |
96 | 96 | getStats($stats->app_clicks); |
97 | - echo "\t\t\t\t Installs:" . PHP_EOL; |
|
97 | + echo "\t\t\t\t Installs:".PHP_EOL; |
|
98 | 98 | getStats($stats->mobile_conversion_installs); |
99 | - echo "\t\t\t\t Checkouts:" . PHP_EOL; |
|
99 | + echo "\t\t\t\t Checkouts:".PHP_EOL; |
|
100 | 100 | getStats($stats->mobile_conversion_checkouts_initiated); |
101 | 101 | } |
102 | 102 | } |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | if ($stat instanceof stdClass) { |
118 | 118 | foreach (get_object_vars($stat) as $key => $val) { |
119 | 119 | if (is_array($val)) { |
120 | - echo "\t\t\t\t\t " . $key . ": " . $val[0] . PHP_EOL; |
|
120 | + echo "\t\t\t\t\t ".$key.": ".$val[0].PHP_EOL; |
|
121 | 121 | } else { |
122 | - echo "\t\t\t\t\t " . $key . " 0" . PHP_EOL; |
|
122 | + echo "\t\t\t\t\t ".$key." 0".PHP_EOL; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } else if (is_array($stat)) { |
126 | 126 | foreach ($stat as $s) { |
127 | - echo $s . PHP_EOL; |
|
127 | + echo $s.PHP_EOL; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | $j = 1; |
38 | 38 | $l = 1; |
39 | 39 | foreach ($campaignsData as $campaign) { |
40 | - echo $i . ": " . $campaign->getId() . " " . $campaign->getName() . " " . $campaign->getStartTime()->format('Y-m-d') . " - " . $campaign->getEntityStatus() . PHP_EOL; |
|
40 | + echo $i.": ".$campaign->getId()." ".$campaign->getName()." ".$campaign->getStartTime()->format('Y-m-d')." - ".$campaign->getEntityStatus().PHP_EOL; |
|
41 | 41 | $lineItems = $campaign->getLineItems([TwitterAds\Fields\LineItemFields::COUNT => 2]); |
42 | 42 | /** @var LineItem $lineItem */ |
43 | 43 | foreach ($lineItems as $lineItem) { |
44 | - echo "\t" . $j . ": " . $lineItem->getId() . " " . $lineItem->getName() . " " . PHP_EOL; |
|
45 | - echo "\t\tBid: " . ($lineItem->getBidAmountLocalMicro() / 1000000) . PHP_EOL; |
|
46 | - echo "\t\tObjective: " . $lineItem->getObjective() . PHP_EOL; |
|
47 | - echo "\t\tCharge By: " . $lineItem->getChargeBy() . PHP_EOL; |
|
48 | - echo "\t\tBid Unit: " . $lineItem->getBidUnit() . PHP_EOL; |
|
49 | - echo "\t\tOptimization: " . $lineItem->getOptimization() . PHP_EOL; |
|
50 | - echo "\t\tBid Type: " . $lineItem->getBidType() . PHP_EOL; |
|
44 | + echo "\t".$j.": ".$lineItem->getId()." ".$lineItem->getName()." ".PHP_EOL; |
|
45 | + echo "\t\tBid: ".($lineItem->getBidAmountLocalMicro() / 1000000).PHP_EOL; |
|
46 | + echo "\t\tObjective: ".$lineItem->getObjective().PHP_EOL; |
|
47 | + echo "\t\tCharge By: ".$lineItem->getChargeBy().PHP_EOL; |
|
48 | + echo "\t\tBid Unit: ".$lineItem->getBidUnit().PHP_EOL; |
|
49 | + echo "\t\tOptimization: ".$lineItem->getOptimization().PHP_EOL; |
|
50 | + echo "\t\tBid Type: ".$lineItem->getBidType().PHP_EOL; |
|
51 | 51 | $targetingCriterias = $lineItem->getTargetingCriteria(); |
52 | 52 | /** @var TwitterAds\Campaign\TargetingCriteria $targetingCriteria */ |
53 | 53 | foreach ($targetingCriterias as $targetingCriteria) { |
54 | - echo "\t\t" . $l . ": " . $targetingCriteria->getId() . " " . $targetingCriteria->getName() . " " . |
|
54 | + echo "\t\t".$l.": ".$targetingCriteria->getId()." ".$targetingCriteria->getName()." ". |
|
55 | 55 | |
56 | - $targetingCriteria->getTargetingType() . " " . $targetingCriteria->getTargetingValue() . PHP_EOL; |
|
56 | + $targetingCriteria->getTargetingType()." ".$targetingCriteria->getTargetingValue().PHP_EOL; |
|
57 | 57 | |
58 | 58 | $l++; |
59 | 59 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | ); |
80 | 80 | $stats = $stats[0]->id_data[0]->metrics; |
81 | 81 | if (!is_null($stats->billed_charge_local_micro)) { |
82 | - echo "\t\t\t Start: " . $date[0]->format('Y-m-d H:i:s') . PHP_EOL; |
|
83 | - echo "\t\t\t End: " . $date[1]->format('Y-m-d H:i:s') . PHP_EOL; |
|
84 | - echo "\t\t\t " . ($stats->billed_charge_local_micro[0] / 1000000) . "€" . PHP_EOL; |
|
82 | + echo "\t\t\t Start: ".$date[0]->format('Y-m-d H:i:s').PHP_EOL; |
|
83 | + echo "\t\t\t End: ".$date[1]->format('Y-m-d H:i:s').PHP_EOL; |
|
84 | + echo "\t\t\t ".($stats->billed_charge_local_micro[0] / 1000000)."€".PHP_EOL; |
|
85 | 85 | echo "\t\t\t\t App clicks: "; |
86 | 86 | getStats($stats->app_clicks); |
87 | - echo "\t\t\t\t Installs:" . PHP_EOL; |
|
87 | + echo "\t\t\t\t Installs:".PHP_EOL; |
|
88 | 88 | getStats($stats->mobile_conversion_installs); |
89 | - echo "\t\t\t\t Checkouts:" . PHP_EOL; |
|
89 | + echo "\t\t\t\t Checkouts:".PHP_EOL; |
|
90 | 90 | getStats($stats->mobile_conversion_checkouts_initiated); |
91 | 91 | } |
92 | 92 | } |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | if ($stat instanceof stdClass) { |
107 | 107 | foreach (get_object_vars($stat) as $key => $val) { |
108 | 108 | if (is_array($val)) { |
109 | - echo "\t\t\t\t\t " . $key . ": " . $val[0] . PHP_EOL; |
|
109 | + echo "\t\t\t\t\t ".$key.": ".$val[0].PHP_EOL; |
|
110 | 110 | } else { |
111 | - echo "\t\t\t\t\t " . $key . " 0" . PHP_EOL; |
|
111 | + echo "\t\t\t\t\t ".$key." 0".PHP_EOL; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } else if (is_array($stat)) { |
115 | 115 | foreach ($stat as $s) { |
116 | - echo $s . PHP_EOL; |
|
116 | + echo $s.PHP_EOL; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 |
@@ -15,8 +15,8 @@ |
||
15 | 15 | const APPROVAL_STATUS = 'approval_status'; |
16 | 16 | const LINE_ITEM_ID = 'line_item_id'; |
17 | 17 | const TWEET_ID = 'tweet_id'; |
18 | - const SCHEDULED_TWEET_IDS = 'scheduled_tweet_ids'; |
|
19 | - const SCHEDULED_TWEET_ID = 'scheduled_tweet_id'; |
|
18 | + const SCHEDULED_TWEET_IDS = 'scheduled_tweet_ids'; |
|
19 | + const SCHEDULED_TWEET_ID = 'scheduled_tweet_id'; |
|
20 | 20 | const ENTITY_STATUS = 'entity_status'; |
21 | 21 | const PROMOTED_TWEET_IDS = 'promoted_tweet_ids'; |
22 | 22 | const LINE_ITEM_IDS = 'line_item_ids'; |