src/whatsprot.class.php
protected function sendRequestFileUpload($b64hash, $type, $size, $filepath, $to, $caption = '')
    {
        $id = $this->createIqId();

        if (!is_array($to)) {
            $to = $this->getJID($to);
        }

        $mediaNode = new ProtocolNode('media', [
            'hash'  => $b64hash,
            'type'  => $type,
            'size'  => $size,
        ], null, null);

        $node = new ProtocolNode('iq', [
            'id'    => $id,
            'to'    => Constants::WHATSAPP_SERVER,
            'type'  => 'set',
            'xmlns' => 'w:m',
        ], [$mediaNode], null);

        //add to queue
        $messageId = $this->createMsgId();
        $this->mediaQueue[$id] = [
            'messageNode' => $node,
            'filePath'    => $filepath,
            'to'          => $to,
            'message_id'  => $messageId,
            'caption'     => $caption,
        ];

        $this->sendNode($node);
        $this->waitForServer($id);

        // Return message ID. Make pull request for this.
        return $messageId;
    }
protected function sendRequestFileUpload($b64hash, $type, $size, $filepath, $to, $caption = '')
    {
        $id = $this->createIqId();

        if (!is_array($to)) {
            $to = $this->getJID($to);
        }

        $mediaNode = new ProtocolNode('media', [
            'hash'  => $b64hash,
            'type'  => $type,
            'size'  => $size,
        ], null, null);

        $node = new ProtocolNode('iq', [
            'id'    => $id,
            'to'    => Constants::WHATSAPP_SERVER,
            'type'  => 'set',
            'xmlns' => 'w:m',
        ], [$mediaNode], null);

        //add to queue
        $messageId = $this->createMsgId();
        $this->mediaQueue[$id] = [
            'messageNode' => $node,
            'filePath'    => $filepath,
            'to'          => $to,
            'message_id'  => $messageId,
            'caption'     => $caption,
        ];

        $this->sendNode($node);
        $this->waitForServer($id);

        // Return message ID. Make pull request for this.
        return $messageId;
    }
protected function sendRequestFileUpload ( $ b64hash , $ type , $ size , $ filepath , $ to , $ caption = '' ) { $ id = $ this -> createIqId ( ) ; if ( ! is_array ( $ to ) ) { $ to = $ this -> getJID ( $ to ) ; } $ mediaNode = new ProtocolNode ( 'media' , [ 'hash' => $ b64hash , 'type' => $ type , 'size' => $ size , ] , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ id , 'to' => Constants :: WHATSAPP_SERVER , 'type' => 'set' , 'xmlns' => 'w:m' , ] , [ $ mediaNode ] , null ) ; //add to queue $ messageId = $ this -> createMsgId ( ) ; $ this -> mediaQueue [ $ id ] = [ 'messageNode' => $ node , 'filePath' => $ filepath , 'to' => $ to , 'message_id' => $ messageId , 'caption' => $ caption , ] ; $ this -> sendNode ( $ node ) ; $ this -> waitForServer ( $ id ) ; // Return message ID. Make pull request for this. return $ messageId ; }
Send request to upload file.

@param string $b64hash  A base64 hash of file
@param string $type     File type
@param string $size     File size
@param string $filepath Path to image file
@param mixed  $to       Recipient(s)
@param string $caption

@return string Message ID
Send request to upload file .