REAST API help
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 15
- Joined: Wed Sep 11, 2013 3:44 pm
REAST API help
Hi Livecoders,
I’ve subscribed to a SMS text message service that uses a simple REST or SOAP API
I’ve built an application in Delphi that use SOAP/ActiveX to dispatch the message and read the response but would really like to use the REST API in a Livecode desktop application, I’m new to Livecode and struggling to understand where to start with this simple task.
Could somebody be kind enough to write me some pseudo code and point me in the right direction: the key elements are:
URL: <THE_URL_TO_SEND_TO>
Method: POST
Authentication: Basic / Session
Example request:
<?xml version='1.0' encoding='UTF-8'?>
<messages>
<accountreference>MYACCOUNTDETAILS</accountreference>
<message>
<to>44xxxxxxxxxx</to>
<body>Hello World!</body>
</message>
</messages>
Response: Content Type: application/xml HTTP Status Code: 200
Thanks in advance.
I did originally post this message in the "complete beginners" forum but now think it may be better posted here. - apologies for double postings as this has now become quite pressing
Col.
I’ve subscribed to a SMS text message service that uses a simple REST or SOAP API
I’ve built an application in Delphi that use SOAP/ActiveX to dispatch the message and read the response but would really like to use the REST API in a Livecode desktop application, I’m new to Livecode and struggling to understand where to start with this simple task.
Could somebody be kind enough to write me some pseudo code and point me in the right direction: the key elements are:
URL: <THE_URL_TO_SEND_TO>
Method: POST
Authentication: Basic / Session
Example request:
<?xml version='1.0' encoding='UTF-8'?>
<messages>
<accountreference>MYACCOUNTDETAILS</accountreference>
<message>
<to>44xxxxxxxxxx</to>
<body>Hello World!</body>
</message>
</messages>
Response: Content Type: application/xml HTTP Status Code: 200
Thanks in advance.
I did originally post this message in the "complete beginners" forum but now think it may be better posted here. - apologies for double postings as this has now become quite pressing
Col.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: REAST API help
Moderation note: A duplicate of this thread was formerly in the "Complete Beginners" section, since deleted so those wanting to reply to this request can know where to do so. Going forward please make only one thread for a given topic, per the Forum Guidelines at http://forums.runrev.com/viewtopic.php?f=4&t=18885. Thanks.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: REAST API help
See the POST command in the Dictionary. For creating the XML data that gets sent, you may also want to filter the Dictionary to find the many commands available via LiveCode's XML external, included in the LiveCode package.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: REAST API help
OK. I see 3 steps.
1 - the header
It's necessary to create a special header.
Put it into a variable (or a field) and then
2 - the query
Here it's very simple, a simple POST command
3 - the server will send back XML data, right ?
Here, you'll need some XML commands.
I advise the stack from Trevor DeVore of Blue Mango Learning Systems.
1 - the header
It's necessary to create a special header.
Put it into a variable (or a field) and then
Code: Select all
libURLSetCustomHTTPHeaders field "MyHeader"
Here it's very simple, a simple POST command
Code: Select all
post tMyQuery to url "http://www.cccc.com/webservice/CAdxSubProgramXml"
put it into tResult
Here, you'll need some XML commands.
I advise the stack from Trevor DeVore of Blue Mango Learning Systems.
-
- Posts: 15
- Joined: Wed Sep 11, 2013 3:44 pm
Re: REAST API help
Thanks for your response - what do I need to put into the "libURLSetCustomHTTPHeaders" ?
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: REAST API help
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: REAST API help
Here is a header I use for a webservice.ckelly5430 wrote:Thanks for your response - what do I need to put into the "libURLSetCustomHTTPHeaders" ?
Code: Select all
POST /adxwsvc/services/CAdxSubProgramXml HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 1871
Host: www.www.www.ww:18980
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)