Announcement

Collapse
No announcement yet.

Can anyone help with this script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can anyone help with this script?

    I am trying to use clickatell.com to send a sms to my phone, and found this example script on their site. I created my api and used the correct credentials in the script, but it won't work, and I know almost nothing about scripts. Any help would be greatly appreciated. Here is the script that I tried, but with the api id removed and my info removed. Thank you all.


    Imports System.Net
    Imports System.IO
    Dim client As WebClient = New WebClient
    ' Add a user agent header in case the requested URI contains a query.
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705")
    client.QueryString.Add("user", "name")
    client.QueryString.Add("password", "pass")
    client.QueryString.Add("api_id", "userid")
    client.QueryString.Add("to", "myemail.com")
    client.QueryString.Add("text", "This message came from the ZEEeeee!!!")
    Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
    Dim data As Stream = client.OpenRead(baseurl)
    Dim reader As StreamReader = New StreamReader(data)
    Dim s As String = reader.ReadToEnd()
    data.Close()
    reader.Close()
    Return

    #2
    What error are you receiving when you run the script?
    -Rupp
    sigpic

    Comment


      #3
      Try this out for size:

      Code:
          Public Sub Main(ByVal Parmsparms As String)
      
              Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
              Dim client As New Net.WebClient
              Dim data As IO.Stream = Nothing
              Dim reader As IO.StreamReader = Nothing
              Dim response As String = String.Empty
      
              Try
      
                  ' Add a user agent header in case the requested URI contains a query.
                  client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705")
      
                  'add parameters
                  client.QueryString.Add("user", "name")
                  client.QueryString.Add("password", "pass")
                  client.QueryString.Add("api_id", "userid")
                  client.QueryString.Add("to", "myemail.com")
                  client.QueryString.Add("text", "This message came from the ZEEeeee!!!")
      
                  data = client.OpenRead(baseurl)
                  reader = New IO.StreamReader(data)
                  response = reader.ReadToEnd()
      
              Catch ex As Exception
                  response = ex.ToString
              Finally
      
                  If data IsNot Nothing Then data.Close()
                  If reader IsNot Nothing Then reader.Close()
      
              End Try
      
              'this should likely be written to a log
              ' Return response 
      
          End Sub

      Comment


        #4
        When you execute this script on the Zee, it will take a LONG time to compile and execute. You'll need to monitor the log file for execution results.
        HS4Pro Running on a Raspberry Pi4
        79 Z-Wave Nodes, 131 Events, 383 Devices
        Z-Wave, UPB, WiFi
        Plugins: EasyTrigger, weatherXML, OMNI, Z-Wave, Tuya, Device History
        HSTouch Clients: 3 Android, 1 Joggler

        Comment


          #5
          thank you!

          Thank you. This works perfectly.

          Comment

          Working...
          X