/** * Execute the console command. * * @return mixed */ public function handle() { $shouldBackfill = $this->option('backfill'); $authToken = LaraditAuth::getScriptAuthenticationManager()->getAccessToken(); Laradit::setAuthToken($authToken); if ($shouldBackfill) { $hasResponse = true; $isInitial = true; $after = null; while ($hasResponse) { $res = $this->fetchLinks($isInitial, $after); $hasResponse = $res['has_response']; $after = $res['after']; $isInitial = false; } } else { $hot_links = Laradit::getListingsResource()->getNewLinks('dailyprogrammer', ['limit' => 1]); $hot_links = collect($hot_links['data']['children']); $hot_links = $hot_links->map(function ($item) { $data = $item['data']; return $this->extractData($data); }); $hot_links->each(function ($item) { $this->createThread($item); }); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $scriptAuth = LaraditAuth::getScriptAuthenticationManager(); $this->info($scriptAuth->getRequestToken()->getBody()->getContents()); }