Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use curl in quick macros
#1
I'm trying to upload an image to groupme through their API using Quick Macros and I am unable to figure out the solution. 
Maybe someone can suggest a way to convert this CURL code into something I can use in QM.  When I run this curl code from a windows command line it works fine.  (obviously I will change the token here so this will not work) 

curl https://image.groupme.com/pictures -X POST -H "X-Access-Token: w2lN1UI55cjTvftTcjlIIZ4gNDnV9nfQeP5kd" -H "Content-Type: image/jpeg" --data-binary @C:\Users\jim\Pictures\GroupMe\example.png

I thought maybe I could modify the DropBox macros but that uses the "application/octet-stream" content_type and for groupme I need to use content type image/jpeg. 

Have a great day. 
Jim
#2
Code:
Copy      Help
_s="curl https://image.groupme.com/pictures -X POST -H ''X-Access-Token: w2lN1UI55cjTvftTcjlIIZ4gNDnV9nfQeP5kd'' -H ''Content-Type: image/jpeg'' --data-binary @C:\Users\jim\Pictures\GroupMe\example.png"
RunConsole2(_s)
#3
That work fine. Is there a way to capture the payload in the response into a variable?

This is the result after running that code. 

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0 100 53094  100   172  100 52922    172  52922  0:00:01 --:--:--  0:00:01 84950 100 53094  100   172  100 52922    172  52922  0:00:01 --:--:--  0:00:01 84950
{"payload":{"url":"https://i.groupme.com/384x384.png.cea4701ef54b42f3a0d4617b88dcf4b9","picture_url":"https://i.groupme.com/384x384.png.cea4701ef54b42f3a0d4617b88dcf4b9"}}

Jim
#4
Ultimately what I needed was the url put into a str var. I used this code to accomplish that, if there is another (better) solution let me know please. 

str s10 s11
_s="curl https://image.groupme.com/pictures -X POST -H ''X-Access-Token: 2lN1UI55cjT2yFKU8icjlIIZ4gNDnV9nfQeP5kd'' -H ''Content-Type: image/jpeg'' --data-binary @C:\Users\jim\Pictures\GroupMe\example.png"
RunConsole2(_s s10 "" 0x200)
if s10
    findrx(s10 "''url'':''(.+)'',''(.+)''" 0 0 s11 1)
else
    out "error"
out s11


Forum Jump:


Users browsing this thread: 1 Guest(s)