Tuesday, March 31, 2015

Send SMS using PHP Language - PHP Snippet

Send SMS using PHP Language - PHP Snippet

Here simple php script that send SMS using Afilnet API, you should login and you will get 10 credits to use this snippet.
   
# send-simple-sms
# Form for sending simple sms through Afilnet. Steps:

# 1. Register in http://www.afilnet.com
# 2. Get credits to send sms
# 3. Import these files to send simple sms in your project

# Afilnet's credentials
$email = "EMAIL"; // your account's email
$pass = "PASS"; // your account's password
# Params of send
$mobile = "DESTINATION"; // target mobile
$idsender = "SENDER"; // Sender, 11 characters maximum
$prefix = "PREFIX"; // country prefix
$sms = "This is a SMS test using HTTP GET"; // SMS to send

$url = "http://www.afilnet.com/http/sms/?email=".$email."&pass=".$pass."&mobile=".$mobile."&id=".urlencode($idsender)."&country=".$prefix."&sms=".urlencode($sms); // request URL

# request HTTP
$response = file_get_contents($url);
if($response) {
switch($response) {
case "OK":
echo "SMS sent successfully";
break;
case "-1":
echo "Error en el login, usuario o clave incorrectas";
break;
default:
echo "You have no credits for sending";
}
} else {
echo "Error in request. Check parameters";
}
Disqus Comments