Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-06-2012, 10:29 AM   PM User | #1
ayex2013
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ayex2013 is an unknown quantity at this point
Sending SMS from my php website script

Good day programmers, please I'm a novice in coding and I need help with a script where people can send invitation message to their friend on my site as sms. I want users on my site to just drop the phone number of their friends only in the html form and it automatically sends the message I have configured to the number the member placed in the form. I'm hosted with hostgator, though I'm in nigeria, I run SMF 2.0.1 forum on my site, my targeted members are nigerians too. I have sms gateway with bbnsms.com, please guyz I need the script and html form for only phone number field(No message Field) as I want to send the same message that I already compose to all the phone numbers. Thanks guyz.
ayex2013 is offline   Reply With Quote
Old 04-06-2012, 10:33 AM   PM User | #2
ayex2013
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ayex2013 is an unknown quantity at this point
SMS Examples

Sending single text message

Code:
http://DomainName/bulksms/bulksms.php?username=xxxx&password=xxxxx&messa
ge=xxxxxx&mobile=9999999999&sender=xxxxxxx
For example the completed URL is:
Code:
http://www.bbnsms.com/bulksms/bulksms.php?username=drogba@bbnsms.com&passwo
rd=mypasswd&message=TestMessage&mobile=238088888888&sender=Fumi

Sending Multiple text message
Code: [Select]

Code:
http://DomainName/bulksms/bulksms.php?username=xxxx&password=xxxxx&messa
ge=xxxxxx&mobile=238088888888, 238088888888, 238088888888, 238088888888,
238088888888&sender=xxxxxxx

The above Url is the basic HTTP BULK link structure where the details about each
parameter is given below:

For example the completed URL is:
Code: [Select]

Code:
http://www.bbnsms.com/bulksms/bulksms.php?username=drogba@bbnsms.com&passwo
rd=mypasswd&message=TestMessage&mobile=238088888888, 238088888888,
238088888888, 238088888888, 238088888888&sender=Kemi


Thats d format of how my sms gateway works with example.
ayex2013 is offline   Reply With Quote
Old 04-06-2012, 11:51 AM   PM User | #3
MarkR
New Coder

 
Join Date: Sep 2011
Posts: 80
Thanks: 0
Thanked 13 Times in 12 Posts
MarkR is an unknown quantity at this point
Have you started/made any progress with this script so far?
__________________
Web Design Newcastle
MarkR is offline   Reply With Quote
Old 04-06-2012, 12:55 PM   PM User | #4
ayex2013
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ayex2013 is an unknown quantity at this point
yo can use ajax
Code:
<script type="text/javascript"><!--
function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}

var mygetrequest=new ajaxRequest()
mygetrequest.onreadystatechange=function(){
 if (mygetrequest.readyState==4){
  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
   document.getElementById("result").innerHTML=mygetrequest.responseText
  }
  else{
   alert("An error has occured making the request")
  }
 }
}
var mobilevalue=encodeURIComponent(document.getElementById("mobile").value)
var textvalue=encodeURIComponent(document.getElementById("message").value)
mygetrequest.open("GET", "http://www.bbnsms.com/bulksms/bulksms.php?username=drogba@bbnsms.com&passwo
rd=mypasswd&message="+textvalue+"&mobile="+mobilevalue+"&sender=Kemi", true)
mygetrequest.send(null)
--></script>
i was given dat on a site bt i dont know what to do next as i dont have programing idea
ayex2013 is offline   Reply With Quote
Old 01-09-2013, 09:31 AM   PM User | #5
AlexCarter87
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
AlexCarter87 is an unknown quantity at this point
Smile

I think you can get any script from here: ozekisms.com
But i insert a code here tno show how to send sms using PHP script.

Code:
<?php

########################################################
# Login information for the SMS Gateway
########################################################

$ozeki_user = "admin";
$ozeki_password = "abc123";
$ozeki_url = "http://127.0.0.1:9501/api?";

########################################################
# Functions used to send the SMS message
########################################################
function httpRequest($url){
    $pattern = "/http...([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
    preg_match($pattern,$url,$args);
    $in = "";
    $fp = fsockopen("$args[1]", $args[2], $errno, $errstr, 30);
    if (!$fp) {
       return("$errstr ($errno)");
    } else {
        $out = "GET /$args[3] HTTP/1.1\r\n";
        $out .= "Host: $args[1]:$args[2]\r\n";
        $out .= "User-agent: Ozeki PHP client\r\n";
        $out .= "Accept: */*\r\n";
        $out .= "Connection: Close\r\n\r\n";

        fwrite($fp, $out);
        while (!feof($fp)) {
           $in.=fgets($fp, 128);
        }
    }
    fclose($fp);
    return($in);
}



function ozekiSend($phone, $msg, $debug=false){
      global $ozeki_user,$ozeki_password,$ozeki_url;

      $url = 'username='.$ozeki_user;
      $url.= '&password='.$ozeki_password;
      $url.= '&action=sendmessage';
      $url.= '&messagetype=SMS:TEXT';
      $url.= '&recipient='.urlencode($phone);
      $url.= '&messagedata='.urlencode($msg);

      $urltouse =  $ozeki_url.$url;
      if ($debug) { echo "Request: <br>$urltouse<br><br>"; }

      //Open the URL to send the message
      $response = httpRequest($urltouse);
      if ($debug) {
           echo "Response: <br><pre>".
           str_replace(array("<",">"),array("&lt;","&gt;"),$response).
           "</pre><br>"; }

      return($response);
}

########################################################
# GET data from sendsms.html
########################################################

$phonenum = $_POST['recipient'];
$message = $_POST['message'];
$debug = true;

ozekiSend($phonenum,$message,$debug);

?>
I hope it helps.
AlexCarter87 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:39 AM.


Advertisement
Log in to turn off these ads.