public function getAllUsers (array $userOpenIDs, callable $callback = null, $lang = 'en')
    {
        if (count($userOpenIDs) < 1) {
            throw new InvalidArgumentException("At least one user is required.");
        } else {
            $userOpenIDs = array_unique(array_values($userOpenIDs));
        }

        // Build requests.
        $requestBuilder = function ($openIDs) use ($lang) {
            foreach ($openIDs as $user) {
                yield new Request('POST', "https://api.weixin.qq.com/cgi-bin/user/info?openid={$user}&lang={$lang}");
            }
        };

        $profiles = [];

        // Set default callback.
        if (! isset($callback)) {
            $profiles = array_combine($userOpenIDs, array_pad([], count($userOpenIDs), null));
            $callback = function (RequestException $error = null, User $user = null) use (&$profiles) {
                if ($user !== null) {
                    $profiles[$user->getOpenID()] = $user;
                }
            };
        }

        // Send requests.
        (new Pool(
            $this->client,
            $requestBuilder($userOpenIDs),
            [
                'fulfilled' => function (ResponseInterface $response, $index) use ($callback) {
                    $json = json_decode($response->getBody());

                    call_user_func($callback, null, new User($json));
                },
                'rejected'  => function (RequestException $reason, $index) use ($callback) {
                    call_user_func($callback, $reason, null);
                },
            ]
        ))->promise()->wait();

        return $profiles;
    }
public function getAllUsers (array $userOpenIDs, callable $callback = null, $lang = 'en')
    {
        if (count($userOpenIDs) < 1) {
            throw new InvalidArgumentException("At least one user is required.");
        } else {
            $userOpenIDs = array_unique(array_values($userOpenIDs));
        }

        // Build requests.
        $requestBuilder = function ($openIDs) use ($lang) {
            foreach ($openIDs as $user) {
                yield new Request('POST', "https://api.weixin.qq.com/cgi-bin/user/info?openid={$user}&lang={$lang}");
            }
        };

        $profiles = [];

        // Set default callback.
        if (! isset($callback)) {
            $profiles = array_combine($userOpenIDs, array_pad([], count($userOpenIDs), null));
            $callback = function (RequestException $error = null, User $user = null) use (&$profiles) {
                if ($user !== null) {
                    $profiles[$user->getOpenID()] = $user;
                }
            };
        }

        // Send requests.
        (new Pool(
            $this->client,
            $requestBuilder($userOpenIDs),
            [
                'fulfilled' => function (ResponseInterface $response, $index) use ($callback) {
                    $json = json_decode($response->getBody());

                    call_user_func($callback, null, new User($json));
                },
                'rejected'  => function (RequestException $reason, $index) use ($callback) {
                    call_user_func($callback, $reason, null);
                },
            ]
        ))->promise()->wait();

        return $profiles;
    }
public function getAllUsers ( array $ userOpenIDs , callable $ callback = null , $ lang = 'en' ) { if ( count ( $ userOpenIDs ) < 1 ) { throw new InvalidArgumentException ( "At least one user is required." ) ; } else { $ userOpenIDs = array_unique ( array_values ( $ userOpenIDs ) ) ; } // Build requests. $ requestBuilder = function ( $ openIDs ) use ( $ lang ) { foreach ( $ openIDs as $ user ) { yield new Request ( 'POST' , "https://api.weixin.qq.com/cgi-bin/user/info?openid={$user}&lang={$lang}" ) ; } } ; $ profiles = [ ] ; // Set default callback. if ( ! isset ( $ callback ) ) { $ profiles = array_combine ( $ userOpenIDs , array_pad ( [ ] , count ( $ userOpenIDs ) , null ) ) ; $ callback = function ( RequestException $ error = null , User $ user = null ) use ( & $ profiles ) { if ( $ user !== null ) { $ profiles [ $ user -> getOpenID ( ) ] = $ user ; } } ; } // Send requests. ( new Pool ( $ this -> client , $ requestBuilder ( $ userOpenIDs ) , [ 'fulfilled' => function ( ResponseInterface $ response , $ index ) use ( $ callback ) { $ json = json_decode ( $ response -> getBody ( ) ) ; call_user_func ( $ callback , null , new User ( $ json ) ) ; } , 'rejected' => function ( RequestException $ reason , $ index ) use ( $ callback ) { call_user_func ( $ callback , $ reason , null ) ; } , ] ) ) -> promise ( ) -> wait ( ) ; return $ profiles ; }
Retrieves the profiles of all the specified WeChat user IDs.

If no callback is supplied, then an array containing the relevant user objects (if the profile request was
successful), or NULL values (if the profile request failed) indexed by the specified profile ID is returned.

<pre>
$returned[ 'user id' ] = new User(); // Successful.
$returned[ 'user id' ] = null; // Failed.
</pre>

If a callback is supplied, then instead of populating an array, the callback will be called on each successful
or failed profile retrieval. The signature of the callback is given below.

For failed profile retrievals, the User object will be NULL.

<pre>
$callback = function (RequestException $error = null, User $user = null) { };
</pre>

@param array    $userOpenIDs The IDs of the users to fetch profiles for.
@param callable $callback    Optional callback to execute on each profile retrieval.
@param string   $lang        The language to retrieve the user's details in.

@return array

@throws InvalidArgumentException
Retrieves the profiles of all the specified WeChat user IDs .