hborras / twitter-php-ads-sdk

A Twitter supported and maintained Ads API SDK for PHP.
55 stars 41 forks source link

Filter campaign #67

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi Borras,

I'm trying to get ads data from my campaigns, for some it works fine for others it never finishes running.

How could I get less data?

This is what I'm doing but doesn't seem to work. Just never stop running and when I go to the UI I see only a few line itens for this add count.

    $campaigns = $account->getCampaigns('', [TwitterAds\Fields\CampaignFields::COUNT => 10]);

    $campaigns->setUseImplicitFetch(true);
    $campaignsData = [];

    $TwitterData = array();

    $this->logging->getLogger()->info('Getting Campaigns');
    foreach ($campaigns as $campaign) {

        // $campaignDate = $campaign->getStartTime()->format('Y-m-d');
        // $campaignname = $campaign->getName();
        $d = date('Y-m-d', strtotime('today -30days'));

        $endDate = ($campaign->getEndTime()->format('Y-m-d'));

        if($endDate > $d){
            $campaignsData[] = $campaign;
        }

    }

    foreach ($campaignsData as $campaign) {

        $lineItems = $campaign->getLineItems([TwitterAds\Fields\LineItemFields::COUNT => 2]);
        $lineItems->setUseImplicitFetch(true);

        foreach ($lineItems as $lineItem) {

            try {
                $async = true;

                $startDate = new \DateTime($campaign->getStartTime()->format('Y-m-d 00:00:00'), new \DateTimeZone('Europe/London'));
                $endDate = new \DateTime('now 00:00:00',new \DateTimeZone('Europe/London'));
                $dates = $this->dateRanges($startDate, $endDate);

                foreach ($dates as $date) {

                    // echo "<pre>";
                    // print_r($date);
                    // echo "</pre>";

                    $job = $lineItem->stats(
                              [
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_BILLING,
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_MEDIA,
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_VIDEO,
                              ],
                              [
                                 TwitterAds\Fields\AnalyticsFields::START_TIME => $date[0],
                                //  TwitterAds\Fields\AnalyticsFields::END_TIME => $date[1],
                                 AnalyticsFields::END_TIME => $date[1],
                                 AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_DAY,
                                 AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER,
                              ], $async
                    );
                         while($job->getStatus() == TwitterAds\Fields\JobFields::PROCESSING){
                            echo 'Job is still processing. Waiting 5 more seconds' .PHP_EOL;
                            $this->logging->getLogger()->info('Job is still processing. Waiting 5 more seconds');
                            $job->read();
                            sleep(5);
                         }
                        if($job->getStatus() == TwitterAds\Fields\JobFields::SUCCESS){
                              $result = gzfile($job->getUrl());
                              $result = implode("", $result);
                              $stats = json_decode($result)->data;
                              $stats = $stats[0]->id_data[0]->metrics;

                                if (!is_null($stats->billed_charge_local_micro)) {
                                    $spendOrg = $this->getStats($stats->billed_charge_local_micro);
                                    $spend = $spendOrg/1000000;

                                    $TwitterData[] = [

                                                'Campaign' => $campaign->getName(),
                                                'CampaignId' => $campaign->getId(),
                                                'AdGroup' => $lineItem->getName(),
                                                'Date' => $date[0],
                                                'CampaignStart' => $campaign->getStartTime()->format('Y-m-d'),
                                                'CampaignEnd' =>  $campaign->getEndTime()->format('Y-m-d'),
                                                'Objective' => $lineItem->getObjective(),
                                                'Impressions' => $this->getStats($stats->impressions),
                                                'Spend' =>  str_replace(',','', number_format($spend, 2)),
                                                'ASBOF'=> number_format($spend * 0.001, 5),
                                                'VideoViews' => $this->getStats($stats->video_total_views),
                                                'VideoPlayed25' => $this->getStats($stats->video_views_25),
                                                'VideoPlayed50' => $this->getStats($stats->video_views_50),
                                                'VideoPlayed75' => $this->getStats($stats->video_views_75),
                                                'VideoCompletions' =>  $this->getStats($stats->video_views_75),
                                                'Engagements' => $this->getStats($stats->engagements),
                                                'Retweets' => $this->getStats($stats->retweets),
                                                'Replies' => $this->getStats($stats->replies),
                                                'Likes' => $this->getStats($stats->likes),
                                                'ThreeS100SVideoViews' => $this->getStats($stats->video_3s100pct_views),
                                                'LinkClicks' =>  $this->getStats($stats->url_clicks),
                                                'Clicks' =>  $this->getStats($stats->clicks),
                                            ];
                                }

                        }
                }

            }catch (\Hborras\TwitterAdsSDK\TwitterAdsException $e) {
                print_r($e->getErrors());
            }
        }

private function dateRanges($startTime, $endTime) { $interval = new \DateInterval('P1D'); $dateRange = new \DatePeriod($startTime, $interval, $endTime);

$previous = null;
$dates = array();
foreach ($dateRange as $dt) {
    $current = $dt;
    if (!empty($previous)) {
        $show = $current;
        $dates[] = array($previous, $show);
    }
    $previous = $current;
}
if (isset($dates[count($dates) - 1])) {
    $dates[] = array($dates[count($dates) - 1][1], $endTime);
} else {
    $dates[] = array($startTime, $endTime);
}
return $dates;

}

Could you please help me to find a better way using your package?

hborras commented 4 years ago

Hello @eblucas-uk

You have this line "$lineItems->setUseImplicitFetch(true);" It means that automatically Cursor class will fetch another request. If you don't set it true, (aka remove that line) you will need manually at the end of the loop call "$lineItems->fetchNext()"

ghost commented 4 years ago

Hello

Thanks for your reply When I use $lineItems->fetchNext();

I get bad request error

Hborras \ TwitterAdsSDK \ TwitterAds \ Errors \ BadRequest (400) BAD_REQUEST

hborras commented 4 years ago

Could you share the whole code and where are you using the "fetchNext()" instruction?

Thanks

ghost commented 4 years ago

public function getTwitterData(Request $request) { $agent = new Agent(['sourceRoot' => realpath('/app')]); $this->logging = new logging('TwitterApi'); $this->logging->getLogger()->info('Started Twitter'); $this->content = Request::all();

    // $this->account_id = $this->content['account_id'];
    // $this->account_id = "xxxxxxxx";
    $this->account_id = "xxxxx";

    $api = TwitterAds::init($this->CONSUMER_KEY, $this->CONSUMER_SECRET, $this->ACCESS_TOKEN, $this->ACCESS_TOKEN_SECRET);

    $account = new Account($this->account_id);
    $account->read();

    $campaigns = $account->getCampaigns();

    // $campaigns->setUseImplicitFetch(true);
    $campaignsData = [];

    $TwitterData = array();
        $i = 0;
        $i1 = 0;
    $this->logging->getLogger()->info('Getting Campaigns');
    foreach ($campaigns as $campaign) {
        $i1++;
        // $campaignDate = $campaign->getStartTime()->format('Y-m-d');
        // $campaignname = $campaign->getName();
        $d = date('Y-m-d', strtotime('today -30days'));

        $endDate = ($campaign->getEndTime()->format('Y-m-d'));

        if($endDate > $d){
            $i++;
            $campaignsData[] = $campaign;
        }

    }

    foreach ($campaignsData as $campaign) {

        $lineItems = $campaign->getLineItems();
        // $lineItems->setUseImplicitFetch(true);

        foreach ($lineItems as $lineItem) {

            // echo "<pre>";
            // print_r($lineItem);
            // echo "</pre>";

            try {
                $async = true;

                $startDate = new \DateTime($campaign->getStartTime()->format('Y-m-d 00:00:00'), new \DateTimeZone('Europe/London'));
                $endDate = new \DateTime('now 00:00:00',new \DateTimeZone('Europe/London'));
                $dates = $this->dateRanges($startDate, $endDate);

                foreach ($dates as $date) {

                    // echo "<pre>";
                    // print_r($date);
                    // echo "</pre>";

                    $job = $lineItem->stats(
                              [
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_BILLING,
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_ENGAGEMENT,
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_MEDIA,
                                 TwitterAds\Fields\AnalyticsFields::METRIC_GROUPS_VIDEO,
                              ],
                              [
                                 TwitterAds\Fields\AnalyticsFields::START_TIME => $date[0],
                                //  TwitterAds\Fields\AnalyticsFields::END_TIME => $date[1],
                                 AnalyticsFields::END_TIME => $date[1],
                                 AnalyticsFields::GRANULARITY => Enumerations::GRANULARITY_DAY,
                                 AnalyticsFields::PLACEMENT => Enumerations::PLACEMENT_ALL_ON_TWITTER,
                              ], $async
                    );
                         while($job->getStatus() == TwitterAds\Fields\JobFields::PROCESSING){
                            echo 'Job is still processing. Waiting 5 more seconds' .PHP_EOL;
                            $this->logging->getLogger()->info('Job is still processing. Waiting 5 more seconds');
                            $job->read();
                            sleep(5);
                         }
                        if($job->getStatus() == TwitterAds\Fields\JobFields::SUCCESS){
                              $result = gzfile($job->getUrl());
                              $result = implode("", $result);
                              $stats = json_decode($result)->data;
                              $stats = $stats[0]->id_data[0]->metrics;

                                if (!is_null($stats->billed_charge_local_micro)) {
                                    $spendOrg = $this->getStats($stats->billed_charge_local_micro);
                                    $spend = $spendOrg/1000000;

                                    $TwitterData[] = [

                                                'Campaign' => $campaign->getName(),
                                                'CampaignId' => $campaign->getId(),
                                                'AdGroup' => $lineItem->getName(),
                                                'Date' => $date[0],
                                                'CampaignStart' => $campaign->getStartTime()->format('Y-m-d'),
                                                'CampaignEnd' =>  $campaign->getEndTime()->format('Y-m-d'),
                                                'Objective' => $lineItem->getObjective(),
                                                'Impressions' => $this->getStats($stats->impressions),
                                                'Spend' =>  str_replace(',','', number_format($spend, 2)),
                                                'ASBOF'=> number_format($spend * 0.001, 5),
                                                'VideoViews' => $this->getStats($stats->video_total_views),
                                                'VideoPlayed25' => $this->getStats($stats->video_views_25),
                                                'VideoPlayed50' => $this->getStats($stats->video_views_50),
                                                'VideoPlayed75' => $this->getStats($stats->video_views_75),
                                                'VideoCompletions' =>  $this->getStats($stats->video_views_75),
                                                'Engagements' => $this->getStats($stats->engagements),
                                                'Retweets' => $this->getStats($stats->retweets),
                                                'Replies' => $this->getStats($stats->replies),
                                                'Likes' => $this->getStats($stats->likes),
                                                'ThreeS100SVideoViews' => $this->getStats($stats->video_3s100pct_views),
                                                'LinkClicks' =>  $this->getStats($stats->url_clicks),
                                                'Clicks' =>  $this->getStats($stats->clicks),
                                            ];
                                }

                        }
                }

            }catch (\Hborras\TwitterAdsSDK\TwitterAdsException $e) {
                print_r($e->getErrors());
            }

        }

        // $lineItems->fetchNext();

    }

    // exit();

    echo "<pre>";
    print_r($TwitterData);
    echo "</pre>";
    // $this->logging->getLogger()->info('Returned Data');
    // return response()->json($TwitterData);
}

Even if I dont use $lineItems->setUseImplicitFetch(true); it never stops running for some account ids... Cant understand why.. there is only 4 camapings with 5 line itens in each campaign but never finishes, its been runing over an our now. For other account id with more campaigns and more line itens it dont happen.

Thanks for your help on this, if you have a better way of doing this I appreciate.

ghost commented 4 years ago

I need to get the data for all campaigns in each accountId, thats what I trying to do

hborras commented 4 years ago

For those accountes where it runs forever. Could it be, because they where created much more time ago?

Take a look at this line:

$startDate = new \DateTime($campaign->getStartTime()->format('Y-m-d 00:00:00'), new \DateTimeZone('Europe/London'));

ghost commented 4 years ago

Hmm I haven't thought about that.

Make sense, will change and let you know. Thank you

ghost commented 4 years ago

Hi Hborras

I'm trying to get only 1 campaign but it seems that the count isnt working

     $campaigns = $account->getCampaigns('', [ 'sort_by' => 'created_at-asc','count' => 1]);

it is returning all campaigns. The sort by is working though.

Do you know how I can get only one?

hborras commented 4 years ago

have you tried

$campaign = new Campaign($campaignId);
$campaign->read();
ghost commented 4 years ago

Do you know why I get this error sometimes? I'm getting data from 4 campaigns but for only one I get this error

ErrorException thrown with message "Undefined index: retry-after"

Stacktrace:

39 ErrorException in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Errors/ServiceUnavailable.php:15

38 Illuminate\Foundation\Bootstrap\HandleExceptions:handleError in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Errors/ServiceUnavailable.php:15

37 Hborras\TwitterAdsSDK\TwitterAds\Errors\ServiceUnavailable:__construct in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:485

36 Hborras\TwitterAdsSDK\TwitterAds:manageErrors in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:447

35 Hborras\TwitterAdsSDK\TwitterAds:http in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:252

34 Hborras\TwitterAdsSDK\TwitterAds:get in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Analytics/Job.php:45

33 Hborras\TwitterAdsSDK\TwitterAds\Analytics\Job:read in /Users/eduardolucas/Documents/Projects/adopssystem/backend/app/Http/Controllers/API/TwitterController.php:107

32 App\Http\Controllers\API\TwitterController:getTwitterData in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54

31 call_user_func_array in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54

30 Illuminate\Routing\Controller:callAction in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45

29 Illuminate\Routing\ControllerDispatcher:dispatch in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219

28 Illuminate\Routing\Route:runController in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176

27 Illuminate\Routing\Route:run in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:681

26 Illuminate\Routing\Router:Illuminate\Routing{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130

25 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41

24 Illuminate\Routing\Middleware\SubstituteBindings:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

23 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:59

22 Illuminate\Routing\Middleware\ThrottleRequests:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

21 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105

20 Illuminate\Pipeline\Pipeline:then in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:683

19 Illuminate\Routing\Router:runRouteWithinStack in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:658

18 Illuminate\Routing\Router:runRoute in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:624

17 Illuminate\Routing\Router:dispatchToRoute in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:613

16 Illuminate\Routing\Router:dispatch in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:170

15 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130

14 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21

13 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

12 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21

11 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

10 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27

9 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

8 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:63

7 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

6 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/fideloper/proxy/src/TrustProxies.php:57

5 Fideloper\Proxy\TrustProxies:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

4 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105

3 Illuminate\Pipeline\Pipeline:then in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:145

2 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:110

1 Illuminate\Foundation\Http\Kernel:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/public/index.php:55

0 require_once in /Users/eduardolucas/Documents/Projects/adopssystem/backend/server.php:21

ghost commented 4 years ago

Hi Hborras,

Has anything changed?

Now I get this error when I try to access the accounts.

Hborras \ TwitterAdsSDK \ TwitterAds \ Errors \ Forbidden (403) FORBIDDEN

Yesterday it was working normally

hborras commented 4 years ago

Have you updated to v6?

Yesterday Twitter deleted v5 access, you need to update the library to v6

ghost commented 4 years ago

Ok thanks.. didnt know that.. its working now

ghost commented 4 years ago

Do you know why I get this error sometimes? I'm getting data from 4 campaigns after a few minutes running I get this error.

ErrorException thrown with message "Undefined index: retry-after"

Stacktrace:

39 ErrorException in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Errors/ServiceUnavailable.php:15

38 Illuminate\Foundation\Bootstrap\HandleExceptions:handleError in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Errors/ServiceUnavailable.php:15

37 Hborras\TwitterAdsSDK\TwitterAds\Errors\ServiceUnavailable:__construct in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:485

36 Hborras\TwitterAdsSDK\TwitterAds:manageErrors in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:447

35 Hborras\TwitterAdsSDK\TwitterAds:http in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:252

34 Hborras\TwitterAdsSDK\TwitterAds:get in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Analytics/Job.php:45

33 Hborras\TwitterAdsSDK\TwitterAds\Analytics\Job:read in /Users/eduardolucas/Documents/Projects/adopssystem/backend/app/Http/Controllers/API/TwitterController.php:107

32 App\Http\Controllers\API\TwitterController:getTwitterData in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54

31 call_user_func_array in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54

30 Illuminate\Routing\Controller:callAction in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45

29 Illuminate\Routing\ControllerDispatcher:dispatch in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219

28 Illuminate\Routing\Route:runController in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176

27 Illuminate\Routing\Route:run in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:681

26 Illuminate\Routing\Router:Illuminate\Routing{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130

25 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41

24 Illuminate\Routing\Middleware\SubstituteBindings:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

23 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:59

22 Illuminate\Routing\Middleware\ThrottleRequests:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

21 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105

20 Illuminate\Pipeline\Pipeline:then in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:683

19 Illuminate\Routing\Router:runRouteWithinStack in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:658

18 Illuminate\Routing\Router:runRoute in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:624

17 Illuminate\Routing\Router:dispatchToRoute in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Routing/Router.php:613

16 Illuminate\Routing\Router:dispatch in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:170

15 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130

14 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21

13 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

12 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21

11 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

10 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27

9 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

8 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:63

7 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

6 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/fideloper/proxy/src/TrustProxies.php:57

5 Fideloper\Proxy\TrustProxies:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171

4 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:105

3 Illuminate\Pipeline\Pipeline:then in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:145

2 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /Users/eduardolucas/Documents/Projects/adopssystem/backend/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:110

1 Illuminate\Foundation\Http\Kernel:handle in /Users/eduardolucas/Documents/Projects/adopssystem/backend/public/index.php:55

0 require_once in /Users/eduardolucas/Documents/Projects/adopssystem/backend/server.php:21

hborras commented 4 years ago

Let me check it!

Thanks!

hborras commented 4 years ago

Twitter Ads API is throwing a 503 code. That code should include a header called "retry-after". Looks like Twitter is not always showing that header.

Download latest version of the library. You will get an error anyway. But the reason is that you're hitting same endpoint too heavily

ghost commented 4 years ago

I downloaded this morning.

Thanks for the feedback. I'll have to split the requests then.