venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.59k stars 2.13k forks source link

Upload image without sending to user #872

Open recoverjp opened 10 years ago

recoverjp commented 10 years ago

Can I upload a picture and catch the filehash and size? Without sending for any user?

Amirjan commented 10 years ago

This is a hash file function: $filehash = base64_encode(hash_file("sha256", $filepath, true)); but only usable when has been saved in whatsapp server. It's possible with upload.

recoverjp commented 10 years ago

And how can I make upload without use sendMessageImage function?

recoverjp commented 10 years ago

I need do upload an image and catch filepath, filehash and filesize.

mgp25 commented 10 years ago

Why do you want to do that? You can upload the file without sending the media file. Check the API code. Follow what sendMessageImage does for example

recoverjp commented 10 years ago

I want to do this for when the user requests an image, I take forward and not upload.

recoverjp commented 10 years ago

When I send an image using sendMessageImage(), it does not return me a valid url for the picture which I sent. But when I get a picture using the getMessages(), it returns me a valid url for the image. Can anyone help me?

Amirjan commented 10 years ago

File name does not matter, you need only file hash and file size to forward media message.

recoverjp commented 10 years ago

Amirjan, but... $this->sendRequestFileUpload($fhash, 'image', $fsize, $filepath, $to);

And public function sendMessageImage($to, $filepath, $storeURLmedia = false, $fsize = 0, $fhash = "")

I need to send the $filepath, no?

recoverjp commented 10 years ago

How long a file is stored in the whatsapp server? For example, I uploaded some files that are no longer working: https://mms890.whatsapp.net/d/tow7dxB9q4CCbkdCL7lVlQHa9igABP_tXdjUMQ/AvZFt377o39nPUgrDKhuu7o3vMcUhWD3kzRu4zJfTMQ_.jpg

mgp25 commented 10 years ago

If you have the file hash and size you dont need to set the path to the file.

WhatsApp media cant be open in browser (computer) try sending that to you

recoverjp commented 10 years ago

mgp25, can be opened yes, look here https://mmi233.whatsapp.net/d/gRHgZg9NwOzHTw-ZTP4OEW2NNYkABQAiGr2ePg/AgR0SehAFz1hRAsVnqcSH5H4qgbKOcN1z1Ce__JeII7L.jpg

recoverjp commented 10 years ago

Ops... here: https://mmi130.whatsapp.net/d/5NcLeFcYt2vWm0DrvLnmboThLUQABQAiLtydvg/Ass5BrtiC_hYbAmMf7qhCzBSFeVD09FnkV5QkfAKbsiV.jpg

Amirjan commented 10 years ago

$w->sendMessageImage($to, 'any.jpg', false,147792, '6h3qcEQw+O+F7gUa5gSqv+yZ1aZ6x32172HvTPBXkSo=');

recoverjp commented 10 years ago

Amirjan, yeah. It worked. Thank so much. My problem now became the files as giving "Media object not found". It is some protection from Whatsapp?

mgp25 commented 10 years ago

Didnt know that media url could be opened. The device app instead of taking the size and hash takes a hash value and the url, stores that data in a .db.

Nope.

I'll try to upload some examples using this lately

Amirjan commented 10 years ago

https://github.com/venomous0x/WhatsAPI/pull/864

recoverjp commented 10 years ago

mgp25, when I receive a file using the api, I can grab the full url and access it via the web. But after a few moments the image is no longer accessible.

recoverjp commented 10 years ago

I developed a website to provide several files that send through whatsapp. For example, audios, videos, pictures. And I need to send these files to the whatsapp server, so that when the user requests this file, it is forwarded. (because it is faster) The problem is that the files are no longer accessible after some time. This is a protection against access via web?

recoverjp commented 10 years ago

Someone let me know how long a file is stored in the whatsapp servers? For example, I have the hash and size of a file. For how long can I forward this file?

mgp25 commented 10 years ago

That is a server side function. I think they dont delete anything, and if they find any file duplicate doesnt upload it. I was able to send a file i uploaded +3 month ago :p

recoverjp commented 10 years ago

mgp25, but why i can't access this file? https://mmi233.whatsapp.net/d/gRHgZg9NwOzHTw-ZTP4OEW2NNYkABQAiGr2ePg/AgR0SehAFz1hRAsVnqcSH5H4qgbKOcN1z1Ce__JeII7L.jpg I sent this file 3 days ago Is it because I accessed it via web?

mgp25 commented 10 years ago

Maybe. You can try sending the media file using the url, and if you receive the media file, thats it :)

shirioko commented 10 years ago

Received media file URLs only have a limited lifetime so people won't use WhatsApp as an image upload service.

recoverjp commented 10 years ago

hmmmmm ... makes sense