Xojo WebService

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

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

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

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

Also check out the Twilio examples here:

  • Examples/Communication/Internet/TwilioAnswerCall
  • Examples/Communication/Internet/TwilioSMS

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

[quote]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)

[/quote]

  1. in the clsSocket class (PageReceived event):
  1. in the SmsRequest method

[quote]…
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[/quote]

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

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

Hi everyone,

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

thank you

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://documentation.xojo.com/topics/communication/internet/accessing_web_services.html

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.

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?