/** * 指定のリストIDから登録されているユーザを登録する * @param [type] $id [description] * @return [type] [description] */ private function createListMembers($id, $cursor = 0) { $param = array('list_id' => $id, 'count' => 5000); if ($cursor) { $param['cursor'] = $cursor; } $members = $this->get('lists/members', $param); $now = \Carbon\Carbon::now('utc')->toDateTimeString(); foreach ($members->users as $key => $value) { $attribute = ["name" => $value->name, "screen_name" => $value->screen_name, "description" => $value->description, 'list_id' => $id, 'created_at' => $now, 'updated_at' => $now]; // TODO: 性能はあまり良くない \App\Models\TwitterUser::updateOrCreate(['id' => $value->id], $attribute); } if ($members->next_cursor) { createListMembers($id, $members->next_cursor); } }
/** * フォローしているユーザを登録 * @return [type] [description] */ public function createFrends($cursor = 0) { $param = array('screen_name' => env('SCREEN_NAME'), 'count' => 200); if ($cursor) { $param['cursor'] = $cursor; } $friends = $this->get('friends/list', $param); // var_dump($friends);exit; $now = \Carbon\Carbon::now('utc')->toDateTimeString(); foreach ($friends->users as $key => $value) { $attribute = ["name" => $value->name, "screen_name" => $value->screen_name, "description" => $value->description, 'created_at' => $now, 'updated_at' => $now]; // TODO: 性能はあまり良くない \App\Models\TwitterUser::updateOrCreate(['id' => $value->id], $attribute); } if ($friends->next_cursor) { self::createFrends($friends->next_cursor); } }