How to use 'media_requestUpload'
I'm trying to send image through youwsup API. Now I'm struggling with uploading image to WhatsApp server via 'media_requestUpload' method. Here is the code:
local_path = "f:\\138.jpg"
mtype = "image"
sha1 = hashlib.sha256()
fp = open(local_path, 'rb')
try:
sha1.update(fp.read())
hsh = base64.b64encode(sha1.digest())
#hsh = base64.b64encode(fp.read())
self.methodsInterface.call("media_requestUpload", (hsh, mtype, os.path.getsize(local_path)))
finally:
fp.close()
The response I get is like this:
<iq type="result" from="s.whatsapp.net" id="upload_3">
<media url="https://mms831.whatsapp.net/u/7h0BYnbLj1moF7FPt-JDiLQVLBMABOJgar0WsQ/AgAjEingnrQ-yTpwvkbpUFf8Kx9UORUd4Wvum2S8XCX6">
</media>
</iq>
The media url shows "invalid upload request".
Any solution here? All I would like to have is just a image url like "https://mms837.whatsapp.net/d/zqga14Oo324uQMhl9Y_BAgTrqss/AjpsQZcsrnupZ2Ig8-WM8L9opgrUlaqiNRYbwMQNSRgc.jpg". Then I could send message correctly.
I don't get what the problem is.
You need to use the provided code to upload the image to that URL. This will return another URL which you can use to send a message.
Nice answer. I used to think the response url for media_requestUpload should be image url. Now I'm using it to upload the image with uploader and getting correct response. Thanks.
how can we get image url? please can you give me example ?
look at wazapp sources
how it is possible using yowsup?
LOL wazapp using yowsup :D
:)
i found solution for image uploading.
first you shoud use media_requestUpload method to send upload request it will return url which you have to pass to message_imageSend for sending image.
When I call the "media_requestUpload" method, I do not get any response from the server. Even though I am listening for "media_uploadRequestSuccess", "media_uploadRequestFailed" and "media_uploadRequestDuplicate", none of their callback fns are triggered. Am a newbie to yowsup, can someone help me here?
@neotheicebird - Check for media_uploadRequestDuplicate :)