Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WestWind and rest and Twilio
Message
From
02/02/2022 13:56:09
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
WestWind and rest and Twilio
Miscellaneous
Thread ID:
01683428
Message ID:
01683428
Views:
98
html
This is curl code that comes from the Twilio web site

curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json \
*!*	--data-urlencode "Body=Hi there" \
*!*	--data-urlencode "From=+15017122661" \
*!*	--data-urlencode "To=+15558675310" \
*!*	-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

I downloaded the shareware version of WestWind. I want to be able to sens SMS with Rick Strahl's tools.

Here's what I tried so far.

DO c:\outilsvfp\westwind\wwClient

*** POST Request
TEXT TO lcJson NOSHOW
{
"Account": "MyAccountInformation",
"AuthToken": "MyTokenInformation",
"Body": "Simple test ",
"From": "+MyTwilioPhoneNumber",
"To": " "+PhoneNumberIWantToCall"
}
ENDTEXT
loHttp = CREATEOBJECT("wwHttp")
loHttp.cContentType = "application/json"
lcResult = loHttp.Post("https://api.twilio.com/2010-04-01/",lcJson)

IF loHttp.nError # 0
MESSAGEBOX( loHttp.cErrorMsg)
ENDIF
IF loHttp.cResultcode # "200"
MESSAGEBOX( "Invalid HTTP response code: " + loHttp.cResultCode)
ENDIF
MESSAGEBOX( lcResult)

That doesn't work

the result to MESSAGEBOX( loHttp.cErrorMsg) is
Method not allowed

The result to MESSAGEBOX( "Invalid HTTP response code: " + loHttp.cResultCode) is
Invalid HTTP response code 405"

The result to MESSAGEBOX( lcResult) is 
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse><RestException><Code>20004</Code><Message>Method not allowed</Message><MoreInfo>https://www.twilio.com/docs/errors/20004</MoreInfo><Status>405</Status></RestException></TwilioResponse>"

html
UPGRADE

I thought that something like this could help

loHttp.AddProperty( "Body", "Simple test")

instead of all the TEXT TO lcJson. No same errors :-(
*******************************************************
Save a tree, eat a beaver.
Denis Chassé
Next
Reply
Map
View

Click here to load this message in the networking platform