Are you URLEncoding the body of the text message?

Also, We have the country code with every phone number including the sending 
phone number (1 for US).  Did you try that?

> On Aug 5, 2019, at 2:06 PM, Jeffrey Kain <jeffrey.k...@gmail.com> wrote:
> 
> Here's what I wrote for our app ($tUserName would be unique to you, along 
> with $tPassword and $tFromNumber). The method HTTP_Request_Build is just 
> building a text variable like:
> 
>    "From=15555555555&To=15555555556&Body=This%20is%20the%20text"
> 
> String_FixURL is just a URL-encode method that Miyako posted awhile back 
> (included at the end of this message).       
> 
> Also note that we're hard-coding the country code at '1' for US numbers only.
> 
>  // Twilio_Send
>  //
>  // $1 - TEXT - SendTo phone number
>  // $2 - TEXT - Message to send
> 
> C_TEXT($1;$tSendToNumber)
> C_TEXT($2;$tMessage)
> $tSendToNumber:=$1
> $tMessage:=$2
> 
> C_TEXT($tURI;$tUserName;$tPassword;$tPlugin;$tInfo;$tFromNumber;$tRequest;$tResponse)
> C_LONGINT($lJson;$lHTTPStatus;$lTimeout;$lPort)
> 
>  // Stuff unique to your Twilio account
> $tUserName:="Your Twilio username"
> $tPassword:="Your Twilio password"
> $tFromNumber:="Your Twilio mobile account number"
> 
> $tURI:="https://api.twilio.com/2010-04-01/Accounts/"+\
>  $tUserName+"/Messages.json"
> $tFromNumber:="+1"+$tFromNumber
> $tSendToNumber:="+1"+$tSendToNumber
>               
> $tRequest:=""
> HTTP_Request_Build (->$tRequest;"From";String_FixURL ($tFromNumber);"*")
> HTTP_Request_Build (->$tRequest;"To";String_FixURL ($tSendToNumber);"*")
> HTTP_Request_Build (->$tRequest;"Body";String_FixURL ($tMessage))
>               
> ARRAY TEXT($atHeaderNames;0)
> ARRAY TEXT($atHeaderValues;0)
> APPEND TO ARRAY($atHeaderNames;"content-type")
> APPEND TO ARRAY($atHeaderValues;"application/x-www-form-urlencoded")
> HTTP AUTHENTICATE ($tUserName;$tPassword;HTTP basic)
> $lTimeout:=10
> $lHTTPStatus:=HTTP Request (HTTP POST 
> method;$tURI;$tRequest;tResponse;$lTimeout;$atHeaderNames;$atHeaderValues)
> 
> 
>  // String_FixURL
>  //
>  // Returns urlencoded string in $0 from the string passed in $1
> 
> C_TEXT($0)
> C_TEXT($1)
>       
> C_TEXT($escaped)
> C_LONGINT($i)
> C_BOOLEAN($shouldEscape)
> C_BLOB($data)
>       
> For ($i;1;Length($1))
>               
>  $char:=Substring($1;$i;1)
>  $code:=Character code($char)
>               
>  $shouldEscape:=False
>               
>  Case of 
>    : ($code=45)
>    : ($code=46)
>    : ($code>47) & ($code<58)
>    : ($code>63) & ($code<91)
>    : ($code=95)
>    : ($code>96) & ($code<123)
>    : ($code=126)
>  Else 
>    $shouldEscape:=True
>  End case 
>               
>  If ($shouldEscape)
>    CONVERT FROM TEXT($char;"utf-8";$data)
>    For ($j;0;BLOB size($data)-1)
>      $hex:=String($data{$j};"&x")
>      $escaped:=$escaped+"%"+Substring($hex;Length($hex)-1)
>    End for 
>  Else 
>    $escaped:=$escaped+$char
>  End if 
>               
> End for 
>       
> $0:=$escaped
> 
>> On Aug 5, 2019, at 1:00 PM, Jim Labos - infobase via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> I tried and was unsuccessful probably because of syntax so I gave up and
>> moved on. I am trying Clickatell soon.
>> 
>> If you have a working example for Twilio I would much appreciate looking at
>> it.
> 

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to