Completed
Push — master ( 3d7154...87dec9 )
by Hector
05:10 queued 02:26
created
examples/tailored_audience.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/TwitterAds/Campaign/Tweet.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/TwitterAds/TailoredAudience/TailoredAudiencePermission.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
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, []);
Please login to merge, or discard this patch.
src/TwitterAds/TailoredAudience/TailoredAudience.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/TONUpload.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
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 89
         $response = $this->getTwitterAds()->post(self::DEFAULT_DOMAIN.self::DEFAULT_RESOURCE.self::DEFAULT_BUCKET, ['raw' => file_get_contents($this->filePath)], $headers);
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
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 99
         $response = $this->getTwitterAds()->put(self::DEFAULT_DOMAIN.$resource, ['raw' => $bytes], $headers);
100 100
 
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/TwitterAds.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $this->method = $method;
367 367
         $this->resource = $path;
368 368
         $this->resetLastResponse();
369
-        if(strpos($path, TONUpload::DEFAULT_DOMAIN) === 0) {
369
+        if (strpos($path, TONUpload::DEFAULT_DOMAIN) === 0) {
370 370
             $url = $path;
371 371
         } else {
372 372
             $url = sprintf('%s/%s/%s', $host, self::API_VERSION, $path);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      * @throws ServerError
393 393
      * @throws ServiceUnavailable
394 394
      */
395
-    public function manageErrors($response){
395
+    public function manageErrors($response) {
396 396
         switch ($this->getLastHttpCode()) {
397 397
             case 400:
398 398
                 throw new BadRequest(TwitterAdsException::BAD_REQUEST, 400, null, $response->errors);
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
         } else {
439 439
             $authorization = 'Authorization: Bearer '.$this->bearer;
440 440
         }
441
-        if(strpos($url, TONUpload::DEFAULT_DOMAIN) === 0) {
441
+        if (strpos($url, TONUpload::DEFAULT_DOMAIN) === 0) {
442 442
             return $this->request($url, $method, $authorization, $parameters, $headers);
443 443
         } else {
444 444
             return $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters, $headers);
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             CURLOPT_CAINFO => __DIR__.DIRECTORY_SEPARATOR.'cacert.pem',
467 467
             CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout,
468 468
             CURLOPT_HEADER => true,
469
-            CURLOPT_HTTPHEADER => array_merge(['Accept: */*', $authorization, 'Expect:'],$headers,['Connection: close']),
469
+            CURLOPT_HTTPHEADER => array_merge(['Accept: */*', $authorization, 'Expect:'], $headers, ['Connection: close']),
470 470
             CURLOPT_RETURNTRANSFER => true,
471 471
             CURLOPT_SSL_VERIFYHOST => 2,
472 472
             CURLOPT_SSL_VERIFYPEER => true,
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
                 break;
490 490
             case 'POST':
491 491
                 $options[CURLOPT_POST] = true;
492
-                if(isset($postfields['raw'])){
492
+                if (isset($postfields['raw'])) {
493 493
                     $options[CURLOPT_POSTFIELDS] = $postfields['raw'];
494 494
                 } else {
495 495
                     $options[CURLOPT_POSTFIELDS] = Util::buildHttpQuery($postfields);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
                 break;
502 502
             case 'PUT':
503 503
                 $options[CURLOPT_CUSTOMREQUEST] = 'PUT';
504
-                if(isset($postfields['raw'])){
504
+                if (isset($postfields['raw'])) {
505 505
                     $options[CURLOPT_POSTFIELDS] = $postfields['raw'];
506 506
                 }
507 507
                 break;
Please login to merge, or discard this patch.