Send simple SMS with PHP


/ Published in: PHP
Save to your folder(s)

Simple script to send SMS throught our HTTP API (Afilnet) with PHP. Steps:
1.- Register in Afilnet. http://www.afilnet.com/anunciante/registrar.php
2.- Login and get credits (10 free) to send SMS
3.- Use this script or html form example include in this download link: http://www.afilnet.com/programacion/sms/PHP/HTTP/examples/send-simple-sms.zip


Copy this code and paste it in your HTML
  1. <?
  2. // Register in http://www.afilnet.com/anunciante/registrar.php
  3. // Login and get credits (10 free)
  4. // Use this script or form include in download link:
  5. // http://www.afilnet.com/programacion/sms/PHP/HTTP/examples/send-simple-sms.zip
  6.  
  7. $email = "EMAIL"; // Afilnet's email
  8. $pass = "PASS"; // Afilnet's password
  9. $mobile = "DESTINATION"; // mobile target
  10. $idsender = "SENDER"; // sender, 11 characters max
  11. $prefix = "PREFIX"; // country prefix
  12. $sms = "This is a test of sms sending"; // sms text
  13.  
  14. $url = "http://www.afilnet.com/http/sms/?email=".$email."&pass=".$pass."&mobile=".$mobile."&id=".urlencode($idsender)."&country=".$prefix."&sms=".urlencode($sms); // request url
  15.  
  16. # http request
  17. $response = file_get_contents($url);
  18. if($response) {
  19. switch($response) {
  20. case "OK":
  21. echo "SMS sent successfully";
  22. break;
  23. case "-1":
  24. echo "Error in login, email or password is wrong";
  25. break;
  26. default:
  27. echo "You have no credits";
  28. }
  29. } else {
  30. echo "Error in request";
  31. }
  32. ?>

URL: http://www.afilnet.com/programacion/sms/PHP/HTTP/examples/sendsimplesmsform.php

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.