arbeite gerade an einem Interface für Pushbullet mit der API, funktioniert bis jetzt alles ganz gut mit TServerXMLHTTPRequest, nur muss ich für den File Upload Parameter setzen die im CURL Beispiel mit -d angegeben werden:
curl --header 'Access-Token: <your_access_token_here>' -X POST https://api.pushbullet.com/v2/upload-request -d file_name=image.png -d file_type=image/png
Wie kann ich diese Parameter mit TServerXMLHTTPRequest setzen ?
Hier ein Beispiel das funktioniert, aber mit JSON request statt -d Parameter
Grüße
Rudolf
Code: Alles auswählen
function pushb_ttt()
******************************************************************
// curl --header 'Access-Token: <your_access_token_here>' -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}'
local cUrl := "https://api.pushbullet.com/v2/pushes"
local cToken := dcc_iniread("FORMCOMMANDER.INI","PUSHBULLET","TESTTOKEN"),xRet
local oHttp := TServerXMLHTTPRequest():New()
local cData := ""
altd()
xRet := oHttp:Open( "POST" , cUrl , .F.)
xRet := oHttp:lIgnoreCertAll := .T.
xRet := oHttp:SetRequestHeader( "Access-Token", cToken )
xRet := oHttp:SetRequestHeader( "Content-Type", "application/json" )
cData := '{'
cData += '"type": "file"'
cData += '"file_name": "' + alltrim(mord->attachpdf) + '"'
cData += '"file_type": "application/pdf"'
cData += ', "title": "' + alltrim(mord->subject) + '"'
cData += ', "body": "Ein neues Formular"'
cData += '}'
xRet := oHttp:Send(cData)
cc := oHttp:responseText
prot("pushmsg:" + CRLF + cc + CRLF,addpath(al_path,"pushbullet.log"))
dcqdebug oHttp:status
dcqdebug cc
return .t.