examples/whatsapp.php
private function sendMessage()
    {
        if (is_array($this->inputs['to'])) {
            $this->connectToWhatsApp();
            foreach ($this->inputs['to'] as $to) {
                if (trim($to) !== '') {
                    if (isset($this->inputs['message']) && trim($this->inputs['message'] !== '')) {
                        $this->wa->sendMessageComposing($to);
                        $this->wa->sendMessage($to, $this->inputs['message']);
                    }
                    if (isset($this->inputs['image']) && $this->inputs['image'] !== false) {
                        $this->wa->sendMessageImage($to, $this->inputs['image']);
                    }
                    if (isset($this->inputs['audio']) && $this->inputs['audio'] !== false) {
                        $this->wa->sendMessageAudio($to, $this->inputs['audio']);
                    }
                    if (isset($this->inputs['video']) && $this->inputs['video'] !== false) {
                        $this->wa->sendMessageVideo($to, $this->inputs['video']);
                    }
                    if (isset($this->inputs['locationname']) && trim($this->inputs['locationname'] !== '')) {
                        $this->wa->sendMessageLocation($to, $this->inputs['userlong'], $this->inputs['userlat'], $this->inputs['locationname'], null);
                    }
                } else {
                    exit(json_encode([
                        'success'  => false,
                        'errormsg' => 'A blank number was provided!',
                        'messages' => $this->messages,
                    ]));
                }
            }

            exit(json_encode([
                'success'  => true,
                'data'     => 'Message Sent!',
                'messages' => $this->messages,
            ]));
        }
        exit(json_encode([
            'success'  => false,
            'errormsg' => 'Provided numbers to send message to were not in valid format.',
        ]));
    }
private function sendMessage()
    {
        if (is_array($this->inputs['to'])) {
            $this->connectToWhatsApp();
            foreach ($this->inputs['to'] as $to) {
                if (trim($to) !== '') {
                    if (isset($this->inputs['message']) && trim($this->inputs['message'] !== '')) {
                        $this->wa->sendMessageComposing($to);
                        $this->wa->sendMessage($to, $this->inputs['message']);
                    }
                    if (isset($this->inputs['image']) && $this->inputs['image'] !== false) {
                        $this->wa->sendMessageImage($to, $this->inputs['image']);
                    }
                    if (isset($this->inputs['audio']) && $this->inputs['audio'] !== false) {
                        $this->wa->sendMessageAudio($to, $this->inputs['audio']);
                    }
                    if (isset($this->inputs['video']) && $this->inputs['video'] !== false) {
                        $this->wa->sendMessageVideo($to, $this->inputs['video']);
                    }
                    if (isset($this->inputs['locationname']) && trim($this->inputs['locationname'] !== '')) {
                        $this->wa->sendMessageLocation($to, $this->inputs['userlong'], $this->inputs['userlat'], $this->inputs['locationname'], null);
                    }
                } else {
                    exit(json_encode([
                        'success'  => false,
                        'errormsg' => 'A blank number was provided!',
                        'messages' => $this->messages,
                    ]));
                }
            }

            exit(json_encode([
                'success'  => true,
                'data'     => 'Message Sent!',
                'messages' => $this->messages,
            ]));
        }
        exit(json_encode([
            'success'  => false,
            'errormsg' => 'Provided numbers to send message to were not in valid format.',
        ]));
    }
private function sendMessage ( ) { if ( is_array ( $ this -> inputs [ 'to' ] ) ) { $ this -> connectToWhatsApp ( ) ; foreach ( $ this -> inputs [ 'to' ] as $ to ) { if ( trim ( $ to ) !== '' ) { if ( isset ( $ this -> inputs [ 'message' ] ) && trim ( $ this -> inputs [ 'message' ] !== '' ) ) { $ this -> wa -> sendMessageComposing ( $ to ) ; $ this -> wa -> sendMessage ( $ to , $ this -> inputs [ 'message' ] ) ; } if ( isset ( $ this -> inputs [ 'image' ] ) && $ this -> inputs [ 'image' ] !== false ) { $ this -> wa -> sendMessageImage ( $ to , $ this -> inputs [ 'image' ] ) ; } if ( isset ( $ this -> inputs [ 'audio' ] ) && $ this -> inputs [ 'audio' ] !== false ) { $ this -> wa -> sendMessageAudio ( $ to , $ this -> inputs [ 'audio' ] ) ; } if ( isset ( $ this -> inputs [ 'video' ] ) && $ this -> inputs [ 'video' ] !== false ) { $ this -> wa -> sendMessageVideo ( $ to , $ this -> inputs [ 'video' ] ) ; } if ( isset ( $ this -> inputs [ 'locationname' ] ) && trim ( $ this -> inputs [ 'locationname' ] !== '' ) ) { $ this -> wa -> sendMessageLocation ( $ to , $ this -> inputs [ 'userlong' ] , $ this -> inputs [ 'userlat' ] , $ this -> inputs [ 'locationname' ] , null ) ; } } else { exit ( json_encode ( [ 'success' => false , 'errormsg' => 'A blank number was provided!' , 'messages' => $ this -> messages , ] ) ) ; } } exit ( json_encode ( [ 'success' => true , 'data' => 'Message Sent!' , 'messages' => $ this -> messages , ] ) ) ; } exit ( json_encode ( [ 'success' => false , 'errormsg' => 'Provided numbers to send message to were not in valid format.' , ] ) ) ; }
Sends a message to a contact.

Depending on the inputs sends a
message/video/image/location message to
a contact.

@return void
Sends a message to a contact .