examples/whatsapp.php
private function getContacts()
    {
        try {
            //Get whatsapp's Groups this user belongs to.
            $this->waGroupList = [];
            $this->getGroupList();
            if (is_array($this->waGroupList)) {
                $this->contacts = array_merge($this->contacts, $this->waGroupList);
            }

            //Get contacts from google if gmail account configured.
            $googleContacts = [];
            if (isset($this->config[$this->from]['email'])) {
                $email = $this->config[$this->from]['email'];

                if (stripos($email, 'gmail') !== false || stripos($email, 'googlemail') !== false) {
                    $google = new GoogleContacts();
                    $googleContacts = $google->getContacts($this->config, $this->from);
                    if (is_array($googleContacts)) {
                        $this->contacts = array_merge($this->contacts, $googleContacts);
                    }
                }
            }

            if (isset($this->contacts)) {
                exit(json_encode([
                    'success'  => true,
                    'type'     => 'contacts',
                    'data'     => $this->contacts,
                    'messages' => $this->messages,
                ]));
            }
        } catch (Exception $e) {
            exit(json_encode([
                'success'  => false,
                'type'     => 'contacts',
                'errormsg' => $e->getMessage(),
            ]));
        }
    }
private function getContacts()
    {
        try {
            //Get whatsapp's Groups this user belongs to.
            $this->waGroupList = [];
            $this->getGroupList();
            if (is_array($this->waGroupList)) {
                $this->contacts = array_merge($this->contacts, $this->waGroupList);
            }

            //Get contacts from google if gmail account configured.
            $googleContacts = [];
            if (isset($this->config[$this->from]['email'])) {
                $email = $this->config[$this->from]['email'];

                if (stripos($email, 'gmail') !== false || stripos($email, 'googlemail') !== false) {
                    $google = new GoogleContacts();
                    $googleContacts = $google->getContacts($this->config, $this->from);
                    if (is_array($googleContacts)) {
                        $this->contacts = array_merge($this->contacts, $googleContacts);
                    }
                }
            }

            if (isset($this->contacts)) {
                exit(json_encode([
                    'success'  => true,
                    'type'     => 'contacts',
                    'data'     => $this->contacts,
                    'messages' => $this->messages,
                ]));
            }
        } catch (Exception $e) {
            exit(json_encode([
                'success'  => false,
                'type'     => 'contacts',
                'errormsg' => $e->getMessage(),
            ]));
        }
    }
private function getContacts ( ) { try { //Get whatsapp's Groups this user belongs to. $ this -> waGroupList = [ ] ; $ this -> getGroupList ( ) ; if ( is_array ( $ this -> waGroupList ) ) { $ this -> contacts = array_merge ( $ this -> contacts , $ this -> waGroupList ) ; } //Get contacts from google if gmail account configured. $ googleContacts = [ ] ; if ( isset ( $ this -> config [ $ this -> from ] [ 'email' ] ) ) { $ email = $ this -> config [ $ this -> from ] [ 'email' ] ; if ( stripos ( $ email , 'gmail' ) !== false || stripos ( $ email , 'googlemail' ) !== false ) { $ google = new GoogleContacts ( ) ; $ googleContacts = $ google -> getContacts ( $ this -> config , $ this -> from ) ; if ( is_array ( $ googleContacts ) ) { $ this -> contacts = array_merge ( $ this -> contacts , $ googleContacts ) ; } } } if ( isset ( $ this -> contacts ) ) { exit ( json_encode ( [ 'success' => true , 'type' => 'contacts' , 'data' => $ this -> contacts , 'messages' => $ this -> messages , ] ) ) ; } } catch ( Exception $ e ) { exit ( json_encode ( [ 'success' => false , 'type' => 'contacts' , 'errormsg' => $ e -> getMessage ( ) , ] ) ) ; } }
Get Contacts from various sources to display in form.

This method will allow you to add contacts from external
sources to add to the "to box" dropdown list on the form.
Currently this can include:
- Whatsapp Groups for the current user
- Google Contacts (if username/password was supplied in config)

@return void
Get Contacts from various sources to display in form .