Sending SMS using URLConnection class

19 views
Skip to first unread message

Junel Garcia

unread,
Feb 9, 2022, 4:24:26 AM2/9/22
to OpenROAD Users Mailing List
I saw this code on GitHub (https://github.com/glabsdev/php/blob/master/sms-mt.php). I am wondering whether it can be also applied on OpenROAD using the URLConnection class. If it is, can you help me do it on OpenROAD?


<?php




$shortcode = "2648";


$access_token = "A-2szoYus7mB13l5axDrr_1234AApSz8eu236GRNsoBQ";


$address = "9771234567";


$clientCorrelator = "264801";


$message = "PHP SMS Test";




$curl = curl_init();


curl_setopt_array($curl, array(


CURLOPT_URL => "https://devapi.globelabs.com.ph/smsmessaging/v1/outbound/".$shortcode."/requests?access_token=".$access_token ,


CURLOPT_RETURNTRANSFER => true,


CURLOPT_ENCODING => "",


CURLOPT_MAXREDIRS => 10,


CURLOPT_TIMEOUT => 30,


CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,


CURLOPT_CUSTOMREQUEST => "POST",


CURLOPT_POSTFIELDS => "{\"outboundSMSMessageRequest\": { \"clientCorrelator\": \"".$clientCorrelator."\", \"senderAddress\": \"".$shortcode."\", \"outboundSMSTextMessage\": {\"message\": \"".$message."\"}, \"address\": \"".$address."\" } }",


CURLOPT_HTTPHEADER => array(


"Content-Type: application/json"


),


));


$response = curl_exec($curl);


$err = curl_error($curl);


curl_close($curl);


if ($err) {


echo "cURL Error #:" . $err;


} else {


echo $response;


}

Bodo Bergmann

unread,
Feb 11, 2022, 5:50:11 AM2/11/22
to openroa...@googlegroups.com

Hi Junel,

 

Of course this should be possible, as it is an HTTP POST request, so the solution should be similar to the Example 7 given in https://docs.actian.com/openroad/11.2/index.html#page/LangRef/UrlConnection_Class_Examples.htm

You just have to replace the values of the CURLOPT_URL and CURLOPT_POSTFIELDS options.

I cannot tell you if the service still exists and the access token, short code and other values used actually work (or if they are just examples), though .

 

Bodo.

Bodo Bergmann
Engineering Architect
Actian | OpenROAD Engineering
www.actian.com
GESELLSCHAFTSANGABEN: Actian Germany GmbH | Sitz der Gesellschaft: Halenreie 42, 22359 Hamburg | Geschäftsführung: Stephen Padgett, Marc Monahan | Handelsregister: Amtsgericht Hamburg | HRB 135991 | USt-IdNr: DE252449897

--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/e05ac15e-a37b-450d-936f-dfc410c39195n%40googlegroups.com.

Junel Garcia

unread,
Feb 14, 2022, 3:53:46 AM2/14/22
to OpenROAD Users Mailing List
Thank you, Sir Bodo!
Reply all
Reply to author
Forward
0 new messages