Xojo WebService

  1. 3 weeks ago

    Hello,

    how can I manage a request to external service (e.g. Twilio SMS) in a WebService I wish to realize with Xojo?

    thank you

  2. I would specify:

    1) my WS accept requests from calling webapps, obtaining all the data for the request to Twilio (mobile number, message, etc)

    2) my WS send a request to Twilio

    3) Twilio send a SMSto the mobile number provided by my WS

    in this scenario, must I use HTTPSocket (or HTTPSecureSocket) ?

    otherwise?

    thank you

  3. Phillip Z

    Nov 19 Pre-Release Testers, Xojo Pro Florence, SC

    Probably Xojo.Net.HTTPSocket as I suspect Twilio might be picky about TLS.

  4. Paul L

    Nov 19 Xojo Inc http://docs.xojo.com

    Yes, Xojo.Net.HTTPSocket is a good choice.

    Also check out the Twilio examples here:

    • Examples/Communication/Internet/TwilioAnswerCall
    • Examples/Communication/Internet/TwilioSMS
  5. how must I use Xojo.Net.HTTPSocket ?

    I've copied all the elements from my other WebApp (where the request to Twilio works properly) to my WS app, but nothing works.

    I try to briefly describe my WS app.

    1) in the App.HandleSpecialURL

    Dim data As Text = DefineEncoding(Request.Entity, Encodings.UTF8).ToText
    Dim json As JSONItem

    Dim Authorization As String = Request.GetRequestHeader("Authorization")
    If Authorization.Trim <> "MyAPIKey" Then
    Request.Print "Unauthorized"
    Return True
    End If

    Select Case Request.Path

    Case "SmsRequest"
    json = SmsRequest(data)
    ...

    2) in the clsSocket class (PageReceived event):

    Dim result As Text = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(Content)

    3) in the SmsRequest method

    ...
    Dim oSocket As New clsSocket

    Dim data As Xojo.Core.MemoryBlock = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(textParams)

    oSocket.SetRequestContent(data, "application/x-www-form-urlencoded")

    Dim url As Text = "https://api.twilio.com/2010-04-01/Accounts/" + accountID + "/Messages.json"

    If oSocket <> Nil Then
    oSocket.Send("POST", url)
    End If

    after oSocket.Send, I receive no SMS from Twilio.

    and how can I receive the result from asynchronous Xojo.Net.HTTPSocket ?

  6. Hi everyone,

    can someone help me?
    I think I'm missing something in this process.

    thank you

  7. Paul L

    Nov 21 Xojo Inc http://docs.xojo.com

    In general you use Xojo.Net.HTTPSocket to send requests to web services such as Twilio and you use App.HandleURL (or HandleSpecialURL) to create your own web service using a Xojo web app.

    There are lots of videos, blog posts and other materials with lots of examples on how to use or make web services here:

    https://docs.xojo.com/UserGuide:Web_Services_Overview

    Most recently, these two blog posts might be helpful:

    It's been a long time since I've used Twilio so I can't provide anything more specific other than to suggest looking over the Twilio examples included with Xojo.

  8. thank you Paul.

    I'm sorry if I don't explain well my problem.

    in a "normal" Xojo web app, I've successfully obtain the response from a web service, using PageReceveid event with WebSessionContext.

    but if my own web service (a Xojo web app) has a method (called by App.HandleSpecialURL) that use Xojo.Net.HTTPSocket to send a request to a web service (Twilio or others), how can it get the response?

or Sign Up to reply!