user = $user; } /** * Execute the job. * * @return void * @throws GuzzleException */ public function handle(): void { $user = $this->user; $params = [ 'jsonrpc' => '2.0', 'id' => 1, 'method' => 'Chain33.Query', 'params' => [ [ 'execer' => 'chat', 'funcName' => 'GetFriends', 'payload' => [ 'mainAddress' => $user->username, 'count' => 2000, ] ] ], ]; $client = new Client([ 'base_uri' => '152.136.224.167:8901' ]); $result = $client->post('', [ 'body' => json_encode($params), ]); $json = json_decode($result->getBody()->getContents(), true); $collect = collect($json['result']['friends']); $AddFriendItem = []; foreach ($collect as $friend) { $target = User::firstOrCreate(['username' => $friend['friendAddress'],]); $AddFriendItem[] = [ "To_Account" => (string) $target->id, "AddSource" => "AddSource_Type_IMPORT" ]; } if (! blank($AddFriendItem)) { $imParams = [ 'From_Account' => (string) $user->id, 'AddFriendItem' => $AddFriendItem, ]; app('im')->send('sns', 'friend_import', $imParams); } } }