how can I manage a request to external service (e.g. Twilio SMS) in a WebService I wish to realize with Xojo?
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) ?
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
Select Case Request.Path
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)
Dim url As Text = "https://api.twilio.com/2010-04-01/Accounts/" + accountID + "/Messages.json"
If oSocket <> Nil Then
after oSocket.Send, I receive no SMS from Twilio.
and how can I receive the result from asynchronous Xojo.Net.HTTPSocket ?
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:
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?