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

Net.FHttp with space in GET command


Question

Posted

Hello,

                I need your advise - I trying to uset Net.FHttp and the GET command to activate motion alarm on my wanscam camera, unfortunately, the command contains SPACE and I cant get it working - any idea pls ?

 

http://192.168.1.23/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-enable=0&-name=1&usr=[YYY] & pwd = [XXX]

 

in web browser if I type this it works, but not in fibaro :

http://192.168.1.23/cgi-bin/hi3510/param.cgi?cmd=setmdattr&-enable=0&-name=1&usr=[YYY]%20&%20pwd%20=%20[XXX]

 

 

Thanks a lot

7 answers to this question

Recommended Posts

  • 0
Posted

use function urlencode() implemented in lua

 

or

function urlencode2(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
fibaro:debug(str)
return str 
end
 

link="http://192.168.1.23/cgi-bin/"..urlencode2("param.cgi?cmd=setmdattr&-enable=0&-name=1&usr=[YYY] & pwd = [XXX]")

 

for test urlencode, the decode function is:

function urldecode(s)
  return string.gsub(s, '%%(%x%x)', 
    function (hex) return string.char(tonumber(hex,16)) end)
end

  • 0
  • Inquirer
  • Posted

    thanks for the hint, unfortunately I dont how to implement it. Actualy this is what Im trying to get working:

     

    device = Net.FHttp("192.168.1.23") 

    data, status = device:GET("cgi-bin/hi3510/param.cgi?cmd=setmdattr&-enable=0&-name=1&usr=[YYY] & pwd = [XXX]")

     

     

    can you pls help me out with the entire code ?

    Thanks

    • 0
    Posted

    As it was written above:

    create function

     

    Please login or register to see this code.

    then in vd make line:

    Please login or register to see this code.

    and finaly call:

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted (edited)

    Great, thanks a lot for support :)

     

    EDIT: Tried right now, and still getting error message on the username and password :(

     

    Edited by Acho
    • 0
    Posted

    Did you remove the space from link around & before pwd?

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    Yes I tried as well - no success :(

     

    The user and pass is surely corecty - coiped from the web browser the working link

    • 0
    Posted

    Long shot: are you sure about that url? Google tells me api for this kind of camera is...

     

    Please login or register to see this link.

     

    The urls look quite similar, but not exactly the same.

     

    Their example also includes the authentication at the start of the URL:

     

    "

    Please login or register to see this link.

    "

     

    None of the examples has spaces in them.

     

    Maybe your browser cached the password? Or stores authentication in a cookie? You could try this. Start "New Incognito Window" in chrome, then paste your URL and see if that works.

     

    I could be talking nonsense because I do not own this kind of device. But I joined other discussions regarding get/post/urlencode and the likes...

     

    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...