Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Simple Post to URL to send SMS


Question

Posted

Hi,

 

I want to send this URL http://192.168.x,x/cgi-bin/sms_send?username=user1&password=user_pass&number=0037060000001&text=testmessage within a HC3 LUA scene 

 

Can someone help me with the appropriate code as I have failed so many times with:

 

 

local mySMSGateway="192.168.1.1"

loacal user="Fred"

local password="ThisWouldBeThePassword"

local mobileNumber ="004412345678"
local textMessage = "Garage door left open"
 
local baseURL = "http://"..mySMSGateway.."/cgi-bin/sms_send?username="..user.."&password="..password.."&number="
 
local http = net.HTTPClient()
    http:request(baseURL..mobileNumber.."&text="..textMessage, {
        options = { method = 'POST', headers = {["content-type"] = "application/binary"}, data = {"body"}, timeout = 2000 },
        success = function(status)
          if status.status ~= 200 and status.status ~= 201 then print("failed"else fibaro.debug("SCENE360","PresentState variable created"end
          --print(status.data);
        end,
        error = function(err) print('[ERROR] ' .. err) end
      })
 
print(responseData)
print(status)

6 answers to this question

Recommended Posts

  • 0
Posted

Probably you need todo GET request without body-data(and not specifying content-type) instead, if your request url(http://192.168.x,x/cgi-bin/sms_send?username=user1&password=user_pass&number=0037060000001&text=testmessage) can send message(for example from Edge,Chrome,Firefox,..) without additional data.

  • 0
Posted (edited)
3 hours ago, BusterB1959 said:

loacal user="Fred"


This won’t help ?
 

 

Edited by SmartHomeEddy
  • Thanks 1
  • 0
  • Inquirer
  • Posted (edited)

    Username and Password are not for real !

    22 hours ago, SmartHomeEddy said:


    This won’t help ?
     

    Username and Password are not the real ones obviously!

     

     

    Edited by BusterB1959
    Did not add text
    • 0
    Posted
    On 12/21/2021 at 1:46 PM, BusterB1959 said:

    loacal

     

    Yes, but what should this do?

    • Thanks 1
    • 0
  • Inquirer
  • Posted

    My ficticous User1 was Fred and password was XXXXXX

     

    Local User: "Fred" - Typo (Loacal v local) was already spotted, well in my tests I just used the whole URL to start.

     

    :-)

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...