Working Code - SMS Twilio
Ok, after a while I started to figure out what I needed to do. Here is the working xbasic code for me.
SO what this does is get the phone numbers from the table called sharedto with a column called "phone" and cycle through them sending an SMS to each phone number retrevied by the sql select statement.
Cool - multiple SMS messaging!
I have to say this is way less involved than trying to setup pushwoosh for SMS messaging - criminy, you have so many other services involved when you consider iOs and Android - firebase, and on and on.
In the end, there are a few minor changes in what Larry posted but not much!
I don't know why, but until I actually used the code Curl-genie myself and compared the results of that with what Larry had I didn't get it!
Now comes the fun part of tweaking it to get the values from the various fields and a more in-depth SQL select statement to allow message blocking by users...
Ok, after a while I started to figure out what I needed to do. Here is the working xbasic code for me.
Code:
FUNCTION SendTw AS C (e as p) debug(1) '==CONNECTION AND VARS dim cn as SQL::Connection dim vHasError as c dim cf_1 as extension::CurlFile dim flag_1 as l dim ce as extension::Curl dim vSendNumber as c vHasError = "N" cn.open("::Name::DropsConn") vTwilioURLPre= "https://api.twilio.com/2010-04-01/Accounts/" vSID = "my-SID-here" vTwilioURL=vTwilioURLPre+vSID+"/Messages.json" vToken = "my-TOKEN-here" vPassword=vSID+":"+vToken vFromNumber="my-TwilioNUMBER-here" vFrom="&From="+vFromNumber vSubject = "New post" vMessage = "There is a post" ' trying to grab all of the recipients phone numbers from the sharedto table - so this will send to multiple people. 'this assumes you have a table called sharedto with columns named phone,notify and userid. vSelect = "SELECT phone FROM sharedto WHERE notify = 'Yes' and userid = 'my-Email-here' " cn.execute(vSelect) ce = extension::Curl.Init() ce.setOpt("URL",vTwilioURL) ce.setOpt("NOPROGRESS",1) ce.setOpt("USERPWD",vPassword) ce.setOpt("USERAGENT","curl/7.34.0") ce.setOpt("MAXREDIRS",50) ce.setOpt("CAINFO","C:\\Program Files (x86)\\a5V12\\CARoot\\ca-cert.pem") ce.setOpt("CAPATH","C:\\Program Files (x86)\\a5V12\\CARoot") ce.setOpt("CUSTOMREQUEST","POST") ce.setOpt("TCP_KEEPALIVE",1) vBody = "Body="+urlencode(vMessage) while eval_valid(cn.ResultSet.data("phone")) vSendNumber= cn.ResultSet.data("phone") vTo="&To=+1"+vSendNumber vPostFields=vBody+vFrom+vTo ce.setOpt("POSTFIELDS",vPostFields) ce.SetOpt("FILE",cf_1) flag_1 = ce.Exec() flag_1 = cn.ResultSet.NextRow() end while ce.close() cn.Close() END FUNCTION
SO what this does is get the phone numbers from the table called sharedto with a column called "phone" and cycle through them sending an SMS to each phone number retrevied by the sql select statement.
Cool - multiple SMS messaging!
I have to say this is way less involved than trying to setup pushwoosh for SMS messaging - criminy, you have so many other services involved when you consider iOs and Android - firebase, and on and on.
In the end, there are a few minor changes in what Larry posted but not much!
I don't know why, but until I actually used the code Curl-genie myself and compared the results of that with what Larry had I didn't get it!
Now comes the fun part of tweaking it to get the values from the various fields and a more in-depth SQL select statement to allow message blocking by users...
Comment