Jump to content

WinHTTP functions


trancexx
 Share

Recommended Posts

Yes, I call pushbullet server that answers with a JSON string with the codes for Amazon server to upload the image; after the image is uploaded, I'll contact again the pushbullet server with the amazon answer, to insert the pic into the text message.

This is the answer from pushbullet:

{"data":{"acl":"public-read","awsaccesskeyid":"AKIAJxxxxxM4GD3W","content-type":"image/jpeg","key":"LETr6pUxxxxxEDAIhpPOe/ImmagineSmall.jpg","policy":"eyKjb25kaxxxxuMjM0MTMwWiJ9","signature":"UX5s1uIyxxxxxxxrGFKcs="},"file_name":"ImmagineSmall.jpg","file_type":"image/jpeg","file_url":"https://dl2.pushbulletusercontent.com/LETr6pxxxxxhpPOe/ImmagineSmall.jpg","upload_url":"https://upload.pushbullet.com/upload-legacy/CvQ0yPe8pgxxxxxxxxsm5ZJ"}

And the variable I strip off is:
 

$awsaccesskeyid = "AKIAJxxxxxM4GD3W"

I put that value into the form for amazon and they give me that err, but in their answer they report the var I sent them:

<AWSAccessKeyId>AKIAJJIxxxxxGD3W</AWSAccessKeyId>

And it's the same exact correct value...

Infact in the previous form with _WinHttpSendRequest there wasn't that err relative to this var, but another one like I posted before. So, it seems the problem is in the POST data of  _WinHttpSimpleFormFill.

Eventually, if you need the previous code to test with a new your pushbullet account, I can post it. Anyway thank you.

Link to comment
Share on other sites

Just to compare the two POST data:

WinHTTP UDF  _WinHttpSimpleFormFill  $sAddData:


Content-Disposition: form-data; name="awsaccesskeyid"

AKIAJxxxxxxxxGD3W
------WinHttpBoundaryLine_79095.88065
Content-Disposition: form-data; name="acl"

public-read
------WinHttpBoundaryLine_79095.88065
Content-Disposition: form-data; name="key"

CBLvAlSFHxxxxxxxxxu7nW9h/ImmagineSmall.jpg
------WinHttpBoundaryLine_79095.88065
Content-Disposition: form-data; name="signature"

UX5s1uIy1ov6+xlj58JY7rGFKcs=
------WinHttpBoundaryLine_79095.88065
Content-Disposition: form-data; name="policy"

eyKjb25kxxxxxxxxuMjM0MTMwWiJ9
------WinHttpBoundaryLine_79095.88065
Content-Disposition: form-data; name="file"; filename="ImmagineSmall.jpg"
Content-Type: image/jpeg

ÿØÿà
>>>>>>Manual form built and pushed with _WinHttpSendRequest  postData:

Content-Disposition: form-data; name="awsaccesskeyid"

AKIAJJxxxxxM4GD3W
75761000
Content-Disposition: form-data; name="acl"

public-read
75761000
Content-Disposition: form-data; name="key"

sNojHiudxxxxxxxxSfBknX/ImmagineSmall.jpg
75761000
Content-Disposition: form-data; name="signature"

UX5s1uIy1ov6+xlj58JY7rGFKcs=
75761000
Content-Disposition: form-data; name="policy"

eyKjb25kxxxxxxxxxjM0MTMwWiJ9
75761000
Content-Disposition: form-data; name="file"; filename="ImmagineSmall.jpg"
Content-Type: image/jpeg
0xFFD8FFE000104A46494600010101006000600000FFDB00430006D6A03BAB5F6FAF498269457C618FFB0AD6C9CC83D4A305186175C1E89BEB3687A3CAEF9D3D21C4558DA6A........................................................6E36D8A00D0F7DE2A9470A197BF3EB1A705C15055F5A650650EAFC1972CD3DC7754680689FFFD9
75761000

The only difference is in the file part: in the first case the file data consists only in 4 chars "ÿØÿà".... whilst in the second there is all the file displayed and so I don't know if in the simpleForm there is the correct last boundary with the closing "--".

Maybe that could be the problem with the server?

Link to comment
Share on other sites

$sToken = "o.553Ycmt4aAwesome7QDvqn00N5p3TGnN"
;...
$sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
        Default, _
        "name:awsaccesskeyid", $awsaccesskeyid, _
        "name:acl", $acl, _
        "name:key", $key, _
        "name:signature", $signature, _
        "name:policy", $policy, _
        "name:file", $sFileToUpload, _
        "Access-Token: " & $sToken)

 

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

20 hours ago, trancexx said:

_WinHttpSimpleFormFill does it correctly.

Do you use the same $hOpen as with previous calls, or you close previous and open new one?

Thank you!

Before I tried with winHTTP, in my previous code, for the first call to pushbullet server, I used this:

local $sPD = '{"file_name": "' & $fileName & '", "file_type": "' & $fileType & '"}'
            $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
            $oHTTP.Open("POST", "https://api.pushbullet.com/v2/upload-request", False)
            $oHTTP.setRequestHeader("Authorization", "Bearer " & $vAccessToken)
            $oHTTP.SetRequestHeader("Content-Type", "application/json")
            $oHTTP.Send($sPD)

maybe the two different call to winHttp had some mismatch... I thought that in every case I had the var I needed, so I made the second call to amazon with your UDF...

EDIT: deleted wrong code....

BUT, I have another problem, this time with the last, second call to pushbullet after uploading the file to amazon, like described here:

https://docs.pushbullet.com/v9/#pushes

I did:

$sPD1 = '{"type":"file" , "file_name":"' & $fileName & '" , "file_url":"' & $fileUrl  & '" , "file_type":"' & $fileType & '" , "body":"' & $body  &'"}'
            ConsoleWrite(">>sPD1 JSON:" & $sPD1 & @CRLF)

            local $hConnect = _WinHttpConnect($hOpen, "https://api.pushbullet.com")
            local  $hRequest = _WinHttpOpenRequest($hConnect, "POST", "v2/pushes", -1, -1, -1, $WINHTTP_FLAG_SECURE) 
            _WinHttpAddRequestHeaders($hRequest, "Authorization: Bearer " & $vAccessToken)
            _WinHttpSendRequest($hRequest, "Content-Type: application/json", $sPD1, StringLen($sPD1))
            _WinHttpReceiveResponse($hRequest)
            local $sHeader, $sResponse
            If _WinHttpQueryDataAvailable($hRequest) Then
                $sHeader = _WinHttpQueryHeaders($hRequest)
                ConsoleWrite("finalHeader:" & $sHeader & @CRLF)
                Do
                    $sResponse &= _WinHttpReadData($hRequest)
                Until @error
            EndIf
            ConsoleWrite("finalRes:" & $sResponse & @CRLF)

With $sPD1 = 

{"type":"file" , "file_name":"Immagine.jpg" , "file_url":"https://dl2.pushbulletusercontent.com/uyxpVnHjxxxxxxxWoJLQ/Immagine.jpg" , "file_type":"image/jpeg" , "body":"test pic"}

file_url is the value obtained from the first answer from pushbullet.

Pushbullet's server answer:

{"error":{"code":"invalid_param","type":"invalid_request","message":"The param 'file_url' has an invalid value.","param":"file_url","cat":"\u003e:3"},"error_code":"invalid_param"}

 

Edited by frank10
Link to comment
Share on other sites

I modified the file_url like: "https:///" instead of "https://" and now it works: it sends the notification and the text message arrives.

BUT there isn't the image! there is only a link, instead of the thumbnail and if click into the link it opens the page with this ERR:

Quote

NoSuchKeyThe specified key does not exist.

EDIT...

Edited by frank10
Link to comment
Share on other sites

I'm sorry!

I had 2 script versions and I made some confusion...

This is the entire code I use now:

local $sPD = '{"file_name": "' & $fileName & '", "file_type": "' & $fileType & '"}'
            ConsoleWrite(">>sPD JSON:" & $sPD & @CRLF)

            local $hOpen = _WinHttpOpen()
            local $hConnect = _WinHttpConnect($hOpen, "https://api.pushbullet.com")
            local  $hRequest = _WinHttpOpenRequest($hConnect, "POST", "v2/upload-request", -1, -1, -1, $WINHTTP_FLAG_SECURE) 
            _WinHttpAddRequestHeaders($hRequest, "Authorization: Bearer " & $vAccessToken)
            local $hSendRequest = _WinHttpSendRequest($hRequest, "Content-Type: application/json", $sPD, StringLen($sPD))
            _WinHttpReceiveResponse($hRequest)
            local $sHeader, $sResponse
            If _WinHttpQueryDataAvailable($hRequest) Then
                $sHeader = _WinHttpQueryHeaders($hRequest)
                Do
                    $sResponse &= _WinHttpReadData($hRequest)
                Until @error
                ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Answer from 1° PUSHBULLET header:" & @CRLF & $sHeader & @CRLF & ">>Response:" & @CRLF &  $sResponse & @CRLF)
            EndIf

            local $json = _JSONDecode($sResponse)
            local $fileUrl = StringTrimLeft(_JSONGet($json, "file_url"), 8)
            local $acl = _JSONGet($json, "data.acl")
            local $awsaccesskeyid = _JSONGet($json, "data.awsaccesskeyid")
            local $key = _JSONGet($json, "data.key")
            local $signature = _JSONGet($json, "data.signature")
            local $policy = _JSONGet($json, "data.policy")
            local $dataUp = _JSONGet($json, "data")
;~          ConsoleWrite($dataUp & @CRLF)
;~          ConsoleWrite($fileUrl & @CRLF) ;
;~          ConsoleWrite($acl & @CRLF)
;~          ConsoleWrite($key & @CRLF) ;
;~          ConsoleWrite($awsaccesskeyid & @CRLF)
;~          ConsoleWrite($signature & @CRLF)
;~          ConsoleWrite($policy & @CRLF)

            Local $hFile = FileOpen($sPath & $fileName, 16)
            local $FileData = FileRead($hFile)

            local $sAddress = "https://s3.amazonaws.com/pushbullet-uploads" 
            local $sFileToUpload = $sPath & $fileName ; upload itself
            local $sForm = _
            '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _
            ' <input type="text" name="awsaccesskeyid"/>' & _ ;
            ' <input type="text" name="acl"/>' & _ ;
            ' <input type="text" name="key"/>' & _ ;
            ' <input type="text" name="signature"/>' & _ ;
            ' <input type="text" name="policy"/>' & _ ;
            ' <input type="file" name="file"/>' & _ ;
            '</form>'

;~          local $hOpen = _WinHttpOpen()
            local $hConnect = $sForm

            $sToken = "o.553Ycmt4aAwesome7QDvqn00N5p3TGnN"
            ;...
            local $sHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
                    Default, _
                    "name:awsaccesskeyid", $awsaccesskeyid , _
                    "name:acl", $acl, _
                    "name:key", $key, _
                    "name:signature", $signature, _
                    "name:policy", $policy, _
                    "name:file", $sFileToUpload, _
                    "Access-Token: " & $sToken)
            ConsoleWrite("> Amazon Server Err:" & @error & "__" & @extended & @CRLF)

            If @error Then
                MsgBox(4096, "Error", "Error number = " & @error)
            Else
                ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Answer from AMAZON:" & @CRLF & $sHTML & @CRLF)
            EndIf

            FileClose($hFile)


            $sPD = '{"type":"file" , "file_name":"' & $fileName & '" , "file_url":"https:///' & $fileUrl  & '" , "file_type":"' & $fileType & '" , "body":"' & $body  &'"}'
            ConsoleWrite(">>sPD1 JSON:" & $sPD & @CRLF)

            local $hConnect = _WinHttpConnect($hOpen, "https://api.pushbullet.com")
            local  $hRequest = _WinHttpOpenRequest($hConnect, "POST", "v2/pushes", -1, -1, -1, $WINHTTP_FLAG_SECURE) 
            _WinHttpAddRequestHeaders($hRequest, "Authorization: Bearer " & $vAccessToken)
            _WinHttpSendRequest($hRequest, "Content-Type: application/json", $sPD, StringLen($sPD))
            ConsoleWrite(">2°pushBullet Server Err:" & @error & "__" & @extended & @CRLF)
            _WinHttpReceiveResponse($hRequest)
            
            local $sHeader, $sResponse
            If _WinHttpQueryDataAvailable($hRequest) Then
                $sHeader = _WinHttpQueryHeaders($hRequest)
                ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Answer from 2° PUSHBULLET  finalHeader:" & @CRLF & $sHeader & @CRLF)
                Do
                    $sResponse &= _WinHttpReadData($hRequest)
                Until @error
            EndIf
            ConsoleWrite(">> finalAnswer:" & @CRLF & $sResponse & @CRLF)
            _WinHttpCloseHandle($hRequest)
            _WinHttpCloseHandle($hConnect)
            _WinHttpCloseHandle($hOpen)

With pushbullet server I have no problems: it answers correctly.

The problem is with Amazon server.

I tried both with and without your Access-Token = same result:

Amazon server answers:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.</Message><AWSAccessKeyId>AKIAJJxxxxxM4GD3W</AWSAccessKeyId><RequestId>2E5E9xxxxxAA8AB9</RequestId><HostId>RSFSw+zFlHwxxxxxxm9a5Gkn/hBe7/NZrIAsLexCOvgxxxxtVoSI=</HostId></Error>

As I said the $awsaccesskeyid has the correct code given by pushbullet.

BTW, is there a way to see the header answer using SimpleFormFill?

Edited by frank10
Link to comment
Share on other sites

Of course. Like this:

;...
$aHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
        Default, _
        "name:awsaccesskeyid", $awsaccesskeyid, _
        "name:acl", $acl, _
        "name:key", $key, _
        "name:signature", $signature, _
        "name:policy", $policy, _
        "name:file", $sFileToUpload, _
        "Access-Token: " & $sToken & _
        "[RETURN_ARRAY]")
        
$sHeader = $aHTML[0] ;<- here it is
$sHTML = $aHTML[1]
;...

 

Btw, the token I gave you is made up. I meant you should use yours (if something like that exists).

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Me too, have no problem using pushbullet TEXT messages.

There is a misunderstanding regard to Amazon:

The problem arises when you want to insert an IMAGE inside these text messages. This is a feature of pushbullet as described in their API.

So, I'm not interested in using Amazon server: it's Pushbullet that uses Amazon server to store the image and then attach it in their text message!

They describe their procedure API here:

https://docs.pushbullet.com/v9/#pushes

Quote

Pushing files is a two-part process: first the file needs to be uploaded, then a push needs to be sent for that file.

To upload a new file, use the upload request endpoint.

Once the file has been uploaded, set the file_name, file_url, and file_type returned in the response to the upload request as the parameters for a new push with type=file.

and here for the part of amazon server:

https://docs.pushbullet.com/v9/#upload-request

I ended up with my previous script, made of 3 process:

1) interrogate pushbullet to have Amazon keys they use for the pic,

2) interrogate Amazon server with the key given by pushbullet to  upload the pic,

3) interrogate again pushbullet server to send text with image inside.

The 2) gives error as previous post...

EDIT:    it gives 403 Forbidden HTTP status code (as in @extended)

In conclusion, solving the Amazon server problem IS necessary to use Pushbullet Image in text.

 

Ok for the token for amazon, but that's not necessary looking the pushbullet API instruction: infact they don't give it.

Edited by frank10
Link to comment
Share on other sites

3 hours ago, frank10 said:

BTW

I already had 1.3.6.9 but the Return_ARRAY  wasn't there! Maybe I downloaded it when it was not official released.

Now I downloaded and installed the same 1.3.6.9, and there is that option!

Yea, the official version has it.

I would like to help you more, but Amazon wants my credit card number for testing. I have no intention giving it to them for something like this. Sorry.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Hu? That's strange!
I don't understand: the only thing I did was to create a free pushbullet account (like yours).

Then you don't need anything else!

Pushbullet doesn't need one to buy an Amazon account to use that feature, it must be free. It's pushbullet that has an account on Amazon that is shared with their users.

Infact the url in which you upload the pic is:

https://s3.amazonaws.com/pushbullet-uploads

So, it's a folder of pushbullet that we, as pushbullet users, can use.

So, nothing related to credit card: I've never asked you to make that... ;)

Link to comment
Share on other sites

6 minutes ago, frank10 said:

I already explained it here, before:

 

You said that the response after your upload request was:

On ‎28‎.‎2‎.‎2016‎. at 2:05 PM, frank10 said:

{"data":{"acl":"public-read","awsaccesskeyid":"AKIAJxxxxxM4GD3W","content-type":"image/jpeg","key":"LETr6pUxxxxxEDAIhpPOe/ImmagineSmall.jpg","policy":"eyKjb25kaxxxxuMjM0MTMwWiJ9","signature":"UX5s1uIyxxxxxxxrGFKcs="},"file_name":"ImmagineSmall.jpg","file_type":"image/jpeg","file_url":"https://dl2.pushbulletusercontent.com/LETr6pxxxxxhpPOe/ImmagineSmall.jpg","upload_url":"https://upload.pushbullet.com/upload-legacy/CvQ0yPe8pgxxxxxxxxsm5ZJ"}

The documentation says that you should upload the file to the upload_url from the response. Correct me if I'm wrong, but that should be

https://upload.pushbullet.com/upload-legacy/CvQ0yPe8pgxxxxxxxxsm5ZJ

What am I reading wrong?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

You are right!

I was reading their examples in API documentation and all of them have:

EXAMPLE RESPONSE

{
  "file_type": "image/png",  "file_type": "image/png",
  "file_name": "image.png",
  "file_url": "https://s3.amazonaws.com/pushbullet-uploads/ubd-VWb1dP5XrZzvHReWHCycIwPyuAMp2R9I/image.png",
  "upload_url": "https://s3.amazonaws.com/pushbullet-uploads"

and

EXAMPLE REQUEST

curl -i -X POST https://s3.amazonaws.com/pushbullet-uploads \
  -F awsaccesskeyid=AKIAJJIUQPUDGPM4GD3W \
  -F acl=public-read \
  etc.....

Reading all that s3.amazonaws.com/pushbullet-uploads, I copied it and put in my request.

I missed that there was also an upload_url in the JSON answer: I thought it was anyway the amazon server as in the examples...

Anyway, thank you: it must be as you said.

Later I will try and I'll tell you.

Link to comment
Share on other sites

global  $vAccessToken = "xxxxxxx"  ; You can find your access token in http://www.pushbullet.com/account

_UploadFilePushBullet( "E:\" , "Pic.jpg" , "image/jpeg", "test pic")

Func _UploadFilePushBullet($sPath, $fileName , $fileType, $body='')
            local $sPD = '{"file_name": "' & $fileName & '", "file_type": "' & $fileType & '"}'
            ConsoleWrite(">>sPD JSON:" & $sPD & @CRLF)

            local $hOpen = _WinHttpOpen()
            local $hConnect = _WinHttpConnect($hOpen, "https://api.pushbullet.com")
            local  $hRequest = _WinHttpOpenRequest($hConnect, "POST", "v2/upload-request", -1, -1, -1, $WINHTTP_FLAG_SECURE) ; SERVE flag_secure!!
            _WinHttpAddRequestHeaders($hRequest, "Authorization: Bearer " & $vAccessToken)
            local $hSendRequest = _WinHttpSendRequest($hRequest, "Content-Type: application/json", $sPD, StringLen($sPD))
            _WinHttpReceiveResponse($hRequest)
            local $sHeader, $sResponse
            If _WinHttpQueryDataAvailable($hRequest) Then
                $sHeader = _WinHttpQueryHeaders($hRequest)
                Do
                    $sResponse &= _WinHttpReadData($hRequest)
                Until @error
                ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Answer from 1° PUSHBULLET header:" & @CRLF & $sHeader & @CRLF & ">>Response:" & @CRLF &  $sResponse & @CRLF)
            EndIf

            local $json = _JSONDecode($sResponse)
            local $fileUrl = StringTrimLeft(_JSONGet($json, "file_url"), 8)
            local $uploadUrl = _JSONGet($json, "upload_url")
            local $acl = _JSONGet($json, "data.acl")
            local $awsaccesskeyid = _JSONGet($json, "data.awsaccesskeyid")
            local $key = _JSONGet($json, "data.key")
            local $signature = _JSONGet($json, "data.signature")
            local $policy = _JSONGet($json, "data.policy")
            local $dataUp = _JSONGet($json, "data")
            ConsoleWrite($dataUp & @CRLF)
            ConsoleWrite($fileUrl & @CRLF) ;
            ConsoleWrite($uploadUrl & @CRLF) ;

            Local $hFile = FileOpen($sPath & $fileName, 16)
            local $FileData = FileRead($hFile)

            local $sFileToUpload = $sPath & $fileName 
            local $sForm = _
            '<form action="' & $uploadUrl & '" method="post" enctype="multipart/form-data">' & _
            ' <input type="text" name="awsaccesskeyid"/>' & _ ;
            ' <input type="text" name="acl"/>' & _ ;
            ' <input type="text" name="key"/>' & _ ;
            ' <input type="text" name="signature"/>' & _ ;
            ' <input type="text" name="policy"/>' & _ ;
            ' <input type="file" name="file"/>' & _ ;
            '</form>'

;~          local $hOpen = _WinHttpOpen()
            local $hConnect = $sForm
            local $aHTML = _WinHttpSimpleFormFill($hConnect, $hOpen, _
                    Default, _
                    "name:awsaccesskeyid", $awsaccesskeyid , _
                    "name:acl", $acl, _
                    "name:key", $key, _
                    "name:signature", $signature, _
                    "name:policy", $policy, _
                    "name:file", $sFileToUpload, _
                    "[RETURN_ARRAY]")
            ConsoleWrite("> 2° pushbullet UPLOAD Server Err:" & @error & "__" & @extended & @CRLF)

            local $sHeader = $aHTML[0]
            local $sHTML = $aHTML[1]

            ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Answer from 2° Pushbullet  header:" & $sHeader & @CRLF & ">> response:" & $sHTML & @CRLF)

            FileClose($hFile)


            $sPD = '{"type":"file" , "file_name":"' & $fileName & '" , "file_url":"https:////' & $fileUrl  & '" , "file_type":"' & $fileType & '" , "body":"' & $body  &'"}'
            ConsoleWrite(">>sPD1 JSON:" & $sPD & @CRLF)

            local $hConnect = _WinHttpConnect($hOpen, "https://api.pushbullet.com")
            local  $hRequest = _WinHttpOpenRequest($hConnect, "POST", "v2/pushes", -1, -1, -1, $WINHTTP_FLAG_SECURE) 
            _WinHttpAddRequestHeaders($hRequest, "Authorization: Bearer " & $vAccessToken)
    _WinHttpSendRequest($hRequest, "Content-Type: application/json", $sPD, StringLen($sPD))
            ConsoleWrite(">3°pushBullet Server Err:" & @error & "__" & @extended & @CRLF)
            _WinHttpReceiveResponse($hRequest)

            local $sHeader, $sResponse
            If _WinHttpQueryDataAvailable($hRequest) Then
                $sHeader = _WinHttpQueryHeaders($hRequest)
                ConsoleWrite(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Answer from 3° PUSHBULLET  finalHeader:" & @CRLF & $sHeader & @CRLF)
                Do
                    $sResponse &= _WinHttpReadData($hRequest)
                Until @error
            EndIf
            ConsoleWrite(">> finalAnswer:" & @CRLF & $sResponse & @CRLF)
            _WinHttpCloseHandle($hRequest)
            _WinHttpCloseHandle($hConnect)
            _WinHttpCloseHandle($hOpen)

    EndFunc

So, the script works, the notification has the pic inside it.

BUT, after about 20 minutes after receiving the message on the smartphone on the pushbullet app, I always receive another message saying "Unable to download the image"... but the image was correctly uploaded, it's there also in the message... ??

Any ideas why?

Could you or someone else try this code with pushbullet to see if even you have that problem or it's only me?

EDIT:

I missed you need also these JSON.au3

#include "JSON.au3"
#include "JSON_Translate.au3"

 

JSON.zip

Edited by frank10
Link to comment
Share on other sites

On ‎29‎.‎2‎.‎2016‎. at 6:18 PM, frank10 said:

I already explained it here, before:

 

First thing, the UDFs inside the zip you posted don't have defined functions you use.
Second thing is why in the world you'd leave unused code inside a reproducer? What FileOpen, FileRead?!?
Third thing is I don't understand why do you constantly choose to make yourself life harder? Use _WinhttpSimpleFormFill(), and ditch JSON construction shit.

Try this ( just set correct access token):

#include "WinHttp.au3"

$sAccessToken = "a.2g3Ymc00aAGgibbbbQDvqnX7u5p3TG34" ; write yours here
$sIden = ""; to whatever device you want

$hOpen = _WinHttpOpen()

; PUSH!!!!!
$sAddress = "https://api.pushbullet.com/v2/pushes"
$sForm = _
        '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _
        ' <input name="device_iden" />' & _
        ' <input name="type" />' & _
        ' <input name="file_name" />' & _
        ' <input name="file_type" />' & _
        ' <input name="file_url" />' & _
        ' <input name="body" />' & _
        '</form>'

$hConnect = $sForm
$sReturnedThing = _WinHttpSimpleFormFill($hConnect, $hOpen, _
        Default, _
        "name:device_iden", $sIden, _
        "name:type", "file", _
        "name:file_name", "picard-wtf.jpg", _
        "name:file_type", "image/jpg", _
        "name:file_url", "http://evolutionaryparenting.com/wp-content/uploads/2015/01/picard-wtf.jpg", _
        "name:body", "Hey!", _
        'Authorization: Bearer ' & $sAccessToken)

MsgBox(4096, "Returned", $sReturnedThing & @CRLF & "@error = " & @error & @CRLF & "@extended = " & @extended)
; Close handles
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

 

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...