public function changeAllGroups (array $userOpenIDs, $groupID)
    {
        if (count($userOpenIDs) < 1) {
            throw new InvalidArgumentException("At least one user is required.");
        }

        // Build requests.
        $requests = function ($users) use ($groupID) {
            foreach (array_chunk($users, 50) as $chunk) {
                yield new Request(
                    "POST",
                    "https://api.weixin.qq.com/cgi-bin/groups/members/batchupdate",
                    [],
                    json_encode([
                        'openid_list' => $chunk,
                        'to_groupid'  => $groupID,
                    ])
                );
            }
        };

        $failed = [];

        (new Pool(
            $this->client,
            $requests($userOpenIDs),
            [   
                'rejected' => function (RequestException $reason) use (&$failed) {
                    $json = json_decode((string)$reason->getRequest()->getBody());

                    if (isset($json->openid_list)) {
                        $failed = array_merge($failed, $json->openid_list);
                    }
                },
            ]
        ))->promise()->wait();

        return $failed;
    }
public function changeAllGroups (array $userOpenIDs, $groupID)
    {
        if (count($userOpenIDs) < 1) {
            throw new InvalidArgumentException("At least one user is required.");
        }

        // Build requests.
        $requests = function ($users) use ($groupID) {
            foreach (array_chunk($users, 50) as $chunk) {
                yield new Request(
                    "POST",
                    "https://api.weixin.qq.com/cgi-bin/groups/members/batchupdate",
                    [],
                    json_encode([
                        'openid_list' => $chunk,
                        'to_groupid'  => $groupID,
                    ])
                );
            }
        };

        $failed = [];

        (new Pool(
            $this->client,
            $requests($userOpenIDs),
            [   
                'rejected' => function (RequestException $reason) use (&$failed) {
                    $json = json_decode((string)$reason->getRequest()->getBody());

                    if (isset($json->openid_list)) {
                        $failed = array_merge($failed, $json->openid_list);
                    }
                },
            ]
        ))->promise()->wait();

        return $failed;
    }
public function changeAllGroups ( array $ userOpenIDs , $ groupID ) { if ( count ( $ userOpenIDs ) < 1 ) { throw new InvalidArgumentException ( "At least one user is required." ) ; } // Build requests. $ requests = function ( $ users ) use ( $ groupID ) { foreach ( array_chunk ( $ users , 50 ) as $ chunk ) { yield new Request ( "POST" , "https://api.weixin.qq.com/cgi-bin/groups/members/batchupdate" , [ ] , json_encode ( [ 'openid_list' => $ chunk , 'to_groupid' => $ groupID , ] ) ) ; } } ; $ failed = [ ] ; ( new Pool ( $ this -> client , $ requests ( $ userOpenIDs ) , [ 'rejected' => function ( RequestException $ reason ) use ( & $ failed ) { $ json = json_decode ( ( string ) $ reason -> getRequest ( ) -> getBody ( ) ) ; if ( isset ( $ json -> openid_list ) ) { $ failed = array_merge ( $ failed , $ json -> openid_list ) ; } } , ] ) ) -> promise ( ) -> wait ( ) ; return $ failed ; }
Changes the group for all the specified users. Returns an array containing the OpenID's of the users that failed
to have their group changed.

@param array $userOpenIDs
@param int   $groupID

@return array
Changes the group for all the specified users . Returns an array containing the OpenID s of the users that failed to have their group changed .