yowsup icon indicating copy to clipboard operation
yowsup copied to clipboard

How to use 'media_requestUpload'

Open xiaojxiao opened this issue 13 years ago • 10 comments

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.

xiaojxiao avatar Jul 26 '13 02:07 xiaojxiao

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.

shirioko avatar Jul 26 '13 05:07 shirioko

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.

xiaojxiao avatar Jul 26 '13 06:07 xiaojxiao

how can we get image url? please can you give me example ?

siddharth7815 avatar Oct 26 '13 12:10 siddharth7815

look at wazapp sources

CODeRUS avatar Oct 26 '13 13:10 CODeRUS

how it is possible using yowsup?

siddharth7815 avatar Oct 26 '13 13:10 siddharth7815

LOL wazapp using yowsup :D

CODeRUS avatar Oct 26 '13 13:10 CODeRUS

:)

siddharth7815 avatar Oct 26 '13 13:10 siddharth7815

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.

siddharth7815 avatar Oct 30 '13 08:10 siddharth7815

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 avatar Feb 04 '14 18:02 neotheicebird

@neotheicebird - Check for media_uploadRequestDuplicate :)

guysch avatar Mar 30 '14 13:03 guysch