This topic is locked
[SOLVED]

 Changing the default Twillio SMS API with your custom SMS API

4/29/2019 3:52:38 AM
PHPRunner General questions
F
fahad225 authorDevClub member

Hi everyone,
Is there anyone who can help me the best I can change the built in Twillio SMS API with my any other SMS API Provider like messagebird.com, so that I can still use the built in phprunner function of sending SMS. I am currently using PHPRunner 9.8 Build 29967.
Thanks in advance.

admin 5/1/2019

Check function common_runner_sms() in source\include\commonfunctions.php file. This is where we send connect to Twilio's website and send a SMS. You can replace Twilio's code with your own.

F
fahad225 authorDevClub member 5/3/2019



Check function common_runner_sms() in source\include\commonfunctions.php file. This is where we send connect to Twilio's website and send a SMS. You can replace Twilio's code with your own.


Thanks Mr. Admin for the quick reply,

I have checked that file and found this function:
function common_runner_sms($number, $message, $parameters = array())

{

global $twilioSID, $twilioAuth, $twilioNumber;
if ( !isset($parameters["To"]) )

$parameters["To"] = $number;
if ( !isset($parameters["Body"]) )

$parameters["Body"] = $message;
$parameters["From"] = $twilioNumber;
$url = "https://api.twilio.com/2010-04-01/Accounts/".$twilioSID."/Messages.json";;
$headers = array();

$headers["User-Agent"] = "twilio-php/5.7.3 (PHP 5.6.12)";

$headers["Accept-Charset"] = "utf-8";

$headers["Content-Type"] = "application/x-www-form-urlencoded";

$headers["Accept"] = "application/json";

$headers["Authorization"] = "Basic " . base64_encode("$twilioSID:$twilioAuth");
$certPath = getabspath('include/cacert.pem');
$result = array();

$result["success"] = false;
$response = runner_post_request($url, $parameters, $headers, $certPath);

if ( !$response["error"] )

{

$result["response"] = my_json_decode($response["content"]);

if ( $result["response"]["status"] == "queued" )

$result["success"] = true;

else

$result["error"] = "Twilio error: " . $result["response"]["message"];

}

else

{

$result["error"] = $response["error"];

}
return $result;

}
So how can I modify this function and then fit it with following http link with parameters:
$username = "testuser";

$password = "password123";

$mno = "252634452512";

$msg = "Test message";

$Sid = "Company name";

$mt = 0;
http://1s2u.net/sms/sendsms/sendsms.asp?username=$username&password=$password&mno=$mno&msg=$msg&Sid=$Sid&mt=$mt
I hope you understood my problem. if you need more clarification I am happy to do it.
Best regards,

admin 5/3/2019

You need to write that code or you need to hire someone to do this for you. Probably this SMS provider has some PHP examples that you can use as a starting point.

F
fahad225 authorDevClub member 5/3/2019



You need to write that code or you need to hire someone to do this for you. Probably this SMS provider has some PHP examples that you can use as a starting point.


Thanks Mr. Admin for your quick reply.
Please could you help me how I can hire someone to do this for me?
Best regards,

admin 5/6/2019

Contact support directly for a quote.