Aller au contenu

Pour Les Spécialistes Http


henri-allauch

Messages recommandés

J'ai essayé plusieurs solutions mais je ne trouve pas la bonne 

--[[
%% properties

%% globals
--]]
   
   -- executer le curl suivant OK depuis console OSX 
   -- curl -d user_credentials= jExZZZZZZZZZZxxx -d "notification[message]=MESSAGE" -d "notification[title]=TITRE" -d "notification[sound]=50"  https://api.faast.io/notifications.json
	
    local http = net.HTTPClient()      
    local requestBody = "user_credentials=jExZZZZZZZZZZxxx&notification[title]=TITRE&notification[message]=MESSAGE&notification[sound]=50"

    response = http:request('https://api.faast.io/notifications.json', {  
        options={ 
            headers = http.controlHeaders, 
            data = requestBody, 
            method ='POST', 
            ---timeout =5000
        }, 
        success = function(response) fibaro:debug("Test OK" ) end,
        error = function(err) fibaro:debug("Test Error: " ..err) end
    })
	http = nil

Quelqu'un a une idée pour intégrer cette commande curl (qui fonctionne correctement depuis une console osx/bsd) dans une scène lua avec net.HTTPClient()

 

Bon week end à  tous   dans le sud on est plus Pastis que bierre ... mais on boit aussi !!!

Lien vers le commentaire
Partager sur d’autres sites

Mais pour ceux qui ne n'on pas bu ..  on doit pouvoir faire plus propre ?

--[[
%% properties

%% globals
--]]
 
	local Serveur =	"https://api.faast.io/notifications.json"
	local user_credentials = "AAAABBBBCCCCDDDDEEEEFFFF"
	local Identifiant = "?user_credentials=" .. user_credentials	
	local message = "MESSAGE"
	local title = "TITRE"
	local sound = "50"
	local Params = "&notification[message]=" ..message .."&notification[title]=" ..title .."&notification[sound]=" ..sound       
	local http = net.HTTPClient()      
        response = http:request(Serveur ..Identifiant .. Params, {  
            options={ 
                method ='POST', 
                ---timeout =5000
            }, 
            success = function(response) fibaro:debug("Test OK" ) end,
            error = function(err) fibaro:debug("Test Error: " ..err) end
        })
	http = nil


Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...