Open faisalcse opened 10 years ago
Recently we update the function to send media messages, so once you have uploaded the video to WhatsApp servers, bind the event to capture the video size and hash, and you don't have to re-upload it:
$w->sendMessageVideo($to, $filepath, false, $fsize, $fhash);
what is $fsize and $fhash? What are the value we have to pass?
You have to use this to capture that:
function onMediaMessageSent(
$phone, // The user phone number including the country code.
$to,
$id,
$filetype,
$url,
$filename,
$filesize,
$filehash,
$icon
);
so...
function onMediaMessageSent( $phone, $to, $id, $filetype, $url, $filename, $filesize, $filehash, $icon){
echo "File size is: $filesize \n\n File hash is: $filehash";
}
$w->eventManager()->bind("onMediaMessageSent", "onMediaMessageSent");
Once you have the size and the hash, you can do this:
$myVideoSize = ""; // here the size you get
$myVideoHash = ""; // here the hash you get
$w->sendMessageVideo($to, $filepath, false, $myVideoSize, $myVideoHash);
Is it updated in the code so that I can take the updates?
Yes, it is updated, you can get the latest code and use it.
I was using the whatsapi code from: https://github.com/shirioko/WhatsAPI/blob/master/src/php/whatsprot.class.php but I see in this code not updated.
Nope, haven't merged @mgp25's latest pull requests into my fork. I'll do it later today.
But I see in the code not updated.
You are using @shirioko 's fork. Use this https://github.com/venomous0x/WhatsAPI
If I copy -> whatsprot.class.php from https://github.com/venomous0x/WhatsAPI and replace in https://github.com/shirioko/WhatsAPI, Will it be ok?
Take the whole code from https://github.com/venomous0x/WhatsAPI Many files have been updated
How can I get the value of $myVideoSize and $myVideoHash?
0.0 i already told you above. Send the video only once. Capture the file size and file hash binding the event with the function i post it above. Once you have that values, send a video message using that values.
Oks, let do a thing, create a file named video.php and put the following code inside:
<?php
require_once 'whatsprot.class.php';
////////////////CONFIGURATION///////////////////////
////////////////////////////////////////////////////
$username = ""; // Your number
$password = ""; // Your password
$nickname = "Nick"; // Your nickname
$debug = false;
$target = ""; // the number you are going to send the media message (the video in this case)
$path = ""; // Path to the video
/////////////////////////////////////////////////////
$w = new WhatsProt($username, null, $nickname, $debug);
function onMediaMessageSent( $phone, $to, $id, $filetype, $url, $filename, $filesize, $filehash, $icon){
echo "File size is: $filesize \n\n File hash is: $filehash";
}
$w->eventManager()->bind("onMediaMessageSent", "onMediaMessageSent");
$w->connect();
$w->loginWithPassword($password);
$w->sendMessageVideo($target, $path);
$w->pollMessages();
$w->disconnect();
?>
And run that script (set your data first), and then post the output and ill guide you.
The output should be similar to this:
File size: 45221
File hash is: hbdkfjjeodnde=
OK let me do it
I Execute the file and output:
File size is: 2164835 File hash is: CGbuo/jRmcmmy0U6h0TrsMB9f4vOm/ZM/JMYwclZRQc=
Now use this:
$myVideoSize = ""; // here the size you get
$myVideoHash = ""; // here the hash you get
$w->sendMessageVideo($to, $filepath, false, $myVideoSize, $myVideoHash);
And it will send the video without re-uploading it to wa servers :)
Can I use this method in bulk.php?
Yes
Image will be the same way?
Yes, and audio too
Shall I need to make Encode the Hash Value because I am passing using POST method?
How can we know it send by hashvalue?
It only sends without re-uploading it to wa servers when you set the size and the file hash, if you dont set that, it will send it normally.
I am trying to send video and it takes time to send. I am trying to send to 8 receiver. The video size is 3MB.
What is the best way to send bulk video?