Notice: ABPro's Stripe payment processor uses the Legacy Checkout and is not SCA compatible. read more..

  • Home
  • How-To
  • Modify ABPro to use Nexmo as your SMS processor

How-To

Modify ABPro to use Nexmo as your SMS processor


Nexmo operates similar to other SMS processors supported by ABPro.

 

This How-To describes a way to modify ABPro so that is calls Nexmo rather than Twillio.
This technique can probably be applied to other providers as well.

 

Edit file: \administrator\components\com_rsappt_pro3\sendmail_pro2.php

 

Around line 915 look for..

//*************** Twilio.com ******************
if($apptpro_config->enable_twilio == "Yes"){

	if($request->sms_dial_code == ""){
		$to=$apptpro_config->clickatell_dialing_code.$sms_phone;
	} else {
		$to=$request->sms_dial_code.$sms_phone;
	}

	require_once JPATH_SITE."/twilio-php/Services/Twilio.php"; 

	// Your Account Sid and Auth Token from twilio.com/user/account
	$sid = $apptpro_config->twilio_sid; 
	$token = $apptpro_config->twilio_token; 
	$client = new Services_Twilio($sid, $token);
	//echo $apptpro_config->twilio_sid."<br/>".$apptpro_config->twilio_token."<br/>".$apptpro_config->twilio_phone."<br/>".$to."<br/>".$message;
	//exit;
//		$sms = $client->account->sms_messages->create($apptpro_config->twilio_phone, $to, $message, array());

	// Added + for non-North American numbers
	$sms = $client->account->sms_messages->create($apptpro_config->twilio_phone, "+".$to, $message, array());
	$returnCode = $sms->sid;
	return true;
}

 

Replace the above with..

//*************** Twilio.com ******************
if($apptpro_config->enable_twilio == "Yes"){

	$ch=curl_init('https://rest.nexmo.com/sms/json?');
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch,CURLOPT_POST,1);
	curl_setopt($ch,CURLOPT_POSTFIELDS,"api_key=".$apptpro_config->twilio_sid.
			"&api_secret=".$apptpro_config->twilio_token.
			"&to=".$sms_phone.
			"&from=".$apptpro_config->twilio_phone.
			"&text=".$message);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	$returnCode = curl_exec($ch);

	return true;
}

 

Now in the Twillio setup screen enter your Nexmo information..

 

 

Now ABPro will call Nexmo rather than Twilio..

 

 

 

 

If you want to make it less confusing for your admin, you can add the following lines to your lanagauge file and the Twilio labels will show Nexmo..

 

Add these line to the bottom of your admin language file, or (better) create language overrides for the keys so they stay when you upgrade ABPro.


RS1_ADMIN_SMS_PROCESSORS_TWILIO_TAB="Nexmo"
RS1_ADMIN_CONFIG_TWILIO_INTRO="To use <a href='http://www.Nexmo.com' target='_blank'>Nexmo.com</a> you need to have an account with them. The values below will be found on your Nexmo.com 'Account' screen.<br/>You will also need to upload the twilio-php helper library to your web server. See setup instructions at appointmentbookingpro.com"
RS1_ADMIN_CONFIG_TWILIO_ENABLE="Enable Nexmo"
RS1_ADMIN_CONFIG_TWILIO_ENABLE_HELP="Yes = Messages will be sent via sms text messaging through your Nexmo.com account.<br>No = No text messaging reminders.<br/>Do Not enable multiple SMS processors."
RS1_ADMIN_CONFIG_TWILIO_SID="Nexmo Key"
RS1_ADMIN_CONFIG_TWILIO_SID_HELP="This is from your Nexmo.com Getting Started screen."
RS1_ADMIN_CONFIG_TWILIO_TOKEN="Nexmo Secret"
RS1_ADMIN_CONFIG_TWILIO_TOKEN_HELP="This is from your Nexmo.com Getting Started screen."
RS1_ADMIN_CONFIG_TWILIO_PHONE="Nexmo Phone Number"
RS1_ADMIN_CONFIG_TWILIO_PHONE_HELP="This is from your Nexmo.com Numbers screen."
RS1_TWILIO_ERR_NO_SID="Nexmo Key missing. Enter the Key from you Nexmo account into the ABPro Nexmo setup screen."
RS1_TWILIO_ERR_NO_TOKEN="Nexmo 'secret' missing. Enter the 'secret' from you Nexmo account into the ABPro Nexmo setup screen."
RS1_TWILIO_ERR_NO_PHONE="Nexmo Phone number missing. Enter the Phone number from you Nexmo account into the ABPro Nexmo setup screen."