@@ -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)) { |
@@ -90,6 +90,12 @@ |
||
| 90 | 90 | return $response; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | + /** |
|
| 94 | + * @param integer $chunkSize |
|
| 95 | + * @param string $bytes |
|
| 96 | + * @param integer $bytesStart |
|
| 97 | + * @param integer $bytesRead |
|
| 98 | + */ |
|
| 93 | 99 | public function uploadChunk($resource, $chunkSize, $bytes, $bytesStart, $bytesRead) |
| 94 | 100 | { |
| 95 | 101 | $headers = [ |
@@ -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 | } |
@@ -18,7 +18,6 @@ |
||
| 18 | 18 | use Hborras\TwitterAdsSDK\TwitterAds\Errors\ServerError; |
| 19 | 19 | use Hborras\TwitterAdsSDK\TwitterAds\Errors\ServiceUnavailable; |
| 20 | 20 | use Hborras\TwitterAdsSDK\Util\JsonDecoder; |
| 21 | -use GuzzleHttp; |
|
| 22 | 21 | |
| 23 | 22 | /** |
| 24 | 23 | * TwitterAds class for interacting with the Twitter API. |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @param string $path |
| 251 | 251 | * @param array $parameters |
| 252 | 252 | * |
| 253 | - * @param array $headers |
|
| 253 | + * @param string[] $headers |
|
| 254 | 254 | * @return Response |
| 255 | 255 | */ |
| 256 | 256 | public function post($path, array $parameters = [], array $headers = []) |
@@ -648,6 +648,10 @@ discard block |
||
| 648 | 648 | // This function takes a input like a=b&a=c&d=e and returns the parsed |
| 649 | 649 | // parameters like this |
| 650 | 650 | // array('a' => array('b','c'), 'd' => 'e') |
| 651 | + |
|
| 652 | + /** |
|
| 653 | + * @param string $input |
|
| 654 | + */ |
|
| 651 | 655 | public static function parse_parameters($input) |
| 652 | 656 | { |
| 653 | 657 | if (!isset($input) || !$input) { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | { |
| 331 | 331 | if ($parameters['media_type'] == 'video/mp4') { |
| 332 | 332 | $parameters['media_category'] = "amplify_video"; |
| 333 | - } elseif($parameters['media_type'] == 'image/gif'){ |
|
| 333 | + } elseif ($parameters['media_type'] == 'image/gif') { |
|
| 334 | 334 | $parameters['media_category'] = 'tweet_gif'; |
| 335 | 335 | } |
| 336 | 336 | |
@@ -413,10 +413,10 @@ discard block |
||
| 413 | 413 | $this->method = $method; |
| 414 | 414 | $this->resource = $path; |
| 415 | 415 | $this->resetLastResponse(); |
| 416 | - if(strpos($path, TONUpload::DEFAULT_DOMAIN) === 0) { |
|
| 416 | + if (strpos($path, TONUpload::DEFAULT_DOMAIN) === 0) { |
|
| 417 | 417 | $url = $path; |
| 418 | 418 | } else { |
| 419 | - if($host == self::UPLOAD_HOST){ |
|
| 419 | + if ($host == self::UPLOAD_HOST) { |
|
| 420 | 420 | $url = sprintf('%s/%s/%s', $host, self::API_REST_VERSION, $path); |
| 421 | 421 | } else { |
| 422 | 422 | $url = sprintf('%s/%s/%s', $host, self::API_VERSION, $path); |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | * @throws ServerError |
| 444 | 444 | * @throws ServiceUnavailable |
| 445 | 445 | */ |
| 446 | - public function manageErrors($response){ |
|
| 446 | + public function manageErrors($response) { |
|
| 447 | 447 | switch ($this->getLastHttpCode()) { |
| 448 | 448 | case 400: |
| 449 | 449 | throw new BadRequest(TwitterAdsException::BAD_REQUEST, 400, null, $response->errors); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | } else { |
| 490 | 490 | $authorization = 'Authorization: Bearer '.$this->bearer; |
| 491 | 491 | } |
| 492 | - if(strpos($url, TONUpload::DEFAULT_DOMAIN) === 0) { |
|
| 492 | + if (strpos($url, TONUpload::DEFAULT_DOMAIN) === 0) { |
|
| 493 | 493 | return $this->request($url, $method, $authorization, $parameters, $headers); |
| 494 | 494 | } else { |
| 495 | 495 | return $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters, $headers); |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | CURLOPT_CAINFO => __DIR__.DIRECTORY_SEPARATOR.'cacert.pem', |
| 518 | 518 | CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout, |
| 519 | 519 | CURLOPT_HEADER => true, |
| 520 | - CURLOPT_HTTPHEADER => array_merge(['Accept: */*', $authorization, 'Expect:'],$headers,['Connection: close']), |
|
| 520 | + CURLOPT_HTTPHEADER => array_merge(['Accept: */*', $authorization, 'Expect:'], $headers, ['Connection: close']), |
|
| 521 | 521 | CURLOPT_RETURNTRANSFER => true, |
| 522 | 522 | CURLOPT_SSL_VERIFYHOST => 2, |
| 523 | 523 | CURLOPT_SSL_VERIFYPEER => true, |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | break; |
| 541 | 541 | case 'POST': |
| 542 | 542 | $options[CURLOPT_POST] = true; |
| 543 | - if(isset($postfields['raw'])){ |
|
| 543 | + if (isset($postfields['raw'])) { |
|
| 544 | 544 | $options[CURLOPT_POSTFIELDS] = $postfields['raw']; |
| 545 | 545 | } else { |
| 546 | 546 | $options[CURLOPT_POSTFIELDS] = Util::buildHttpQuery($postfields); |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | break; |
| 553 | 553 | case 'PUT': |
| 554 | 554 | $options[CURLOPT_CUSTOMREQUEST] = 'PUT'; |
| 555 | - if(isset($postfields['raw'])){ |
|
| 555 | + if (isset($postfields['raw'])) { |
|
| 556 | 556 | $options[CURLOPT_POSTFIELDS] = $postfields['raw']; |
| 557 | 557 | } |
| 558 | 558 | break; |
@@ -717,9 +717,9 @@ discard block |
||
| 717 | 717 | $token = $token['oauth_token']; |
| 718 | 718 | } |
| 719 | 719 | if (empty($sign_in_with_twitter)) { |
| 720 | - return $this->authorizeURL() . "?oauth_token={$token}"; |
|
| 720 | + return $this->authorizeURL()."?oauth_token={$token}"; |
|
| 721 | 721 | } else { |
| 722 | - return $this->authenticateURL() . "?oauth_token={$token}"; |
|
| 722 | + return $this->authenticateURL()."?oauth_token={$token}"; |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | |
@@ -2,12 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience; |
| 4 | 4 | |
| 5 | -use Hborras\TwitterAdsSDK\TONUpload; |
|
| 6 | 5 | use Hborras\TwitterAdsSDK\TwitterAds; |
| 7 | -use Hborras\TwitterAdsSDK\TwitterAds\Account; |
|
| 8 | 6 | use Hborras\TwitterAdsSDK\TwitterAds\Cursor; |
| 9 | 7 | use Hborras\TwitterAdsSDK\TwitterAds\Resource; |
| 10 | -use Hborras\TwitterAdsSDK\TwitterAds\TailoredAudience\Exception\InvalidType; |
|
| 11 | 8 | |
| 12 | 9 | final class TailoredAudiencePermission extends Resource |
| 13 | 10 | { |
@@ -2,11 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Hborras\TwitterAdsSDK\TwitterAds; |
| 4 | 4 | use Hborras\TwitterAdsSDK\TwitterAds\Account; |
| 5 | -use Hborras\TwitterAdsSDK\TwitterAds\Analytics; |
|
| 6 | -use Hborras\TwitterAdsSDK\TwitterAds\Campaign\Campaign; |
|
| 7 | -use Hborras\TwitterAdsSDK\TwitterAds\Campaign\LineItem; |
|
| 8 | -use Hborras\TwitterAdsSDK\TwitterAds\Enumerations; |
|
| 9 | -use Hborras\TwitterAdsSDK\TwitterAds\Fields\AnalyticsFields; |
|
| 10 | 5 | |
| 11 | 6 | require '../autoload.php'; |
| 12 | 7 | |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Hborras\TwitterAdsSDK\TwitterAds; |
| 6 | 6 | use Hborras\TwitterAdsSDK\TwitterAds\Resource; |
| 7 | -use Hborras\TwitterAdsSDK\TwitterAds\Account; |
|
| 8 | 7 | use Hborras\TwitterAdsSDK\Arrayable; |
| 9 | 8 | use Hborras\TwitterAdsSDK\TwitterAds\Errors\BatchLimitExceeded; |
| 10 | 9 | |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | * @param $metricGroups |
| 69 | 69 | * @param array $params |
| 70 | 70 | * @param bool $async |
| 71 | - * @return mixed |
|
| 71 | + * @return Campaign |
|
| 72 | 72 | */ |
| 73 | 73 | public function stats($metricGroups, $params = [], $async = false) |
| 74 | 74 | { |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | namespace Hborras\TwitterAdsSDK\TwitterAds\Campaign; |
| 9 | 9 | |
| 10 | 10 | use Hborras\TwitterAdsSDK\TwitterAds\Analytics; |
| 11 | -use Hborras\TwitterAdsSDK\TwitterAds\Enumerations; |
|
| 12 | 11 | use Hborras\TwitterAdsSDK\TwitterAds\Fields\AnalyticsFields; |
| 13 | 12 | use Hborras\TwitterAdsSDK\TwitterAds\Fields\CampaignFields; |
| 14 | 13 | |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | * @param $metricGroups |
| 83 | 83 | * @param array $params |
| 84 | 84 | * @param bool $async |
| 85 | - * @return mixed |
|
| 85 | + * @return LineItem |
|
| 86 | 86 | */ |
| 87 | 87 | public function stats($metricGroups, $params = [], $async = false) |
| 88 | 88 | { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | * @param $metricGroups |
| 42 | 42 | * @param array $params |
| 43 | 43 | * @param bool $async |
| 44 | - * @return mixed |
|
| 44 | + * @return PromotedTweet |
|
| 45 | 45 | */ |
| 46 | 46 | public function stats($metricGroups, $params = [], $async = false) |
| 47 | 47 | { |