IT Community - Software Programming, Web Development and Technical Support

Sending message to mobile using php

This is a discussion on Sending message to mobile using php within the PHP Programming forums, part of the Web Development category; hi. It is possible to send message to mobile using php coding....


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-17-2007, 05:44 AM
saravanan saravanan is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Posts: 181
saravanan is on a distinguished road
Exclamation Sending message to mobile using php

hi.

It is possible to send message to mobile using php coding.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-27-2007, 01:54 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: Sending message to mobile using php

hi saravanan,

yes,its possible Sending message to mobile using php. but before you register any gate way.
Example gateway site CLICKATELL. For more information about CLICKATELL service visit Clickatell Bulk SMS Gateway

Last edited by senraj : 12-27-2007 at 01:58 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-27-2007, 03:58 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: Sending message to mobile using php

sms_api.php
-------------------

class sms {
var $api_id = "YOUR_CLICKATELL_API_NUMBER";
var $user = "name";
var $password = "password";
var $use_ssl = false;
var $balace_limit = 0;
var $sending_method = "fopen";
var $curl_use_proxy = false;
var $curl_proxy = "http://192.168.122.1";
var $curl_proxyuserpwd = "login:secretpass";
var $callback = 0;
var $session;
function sms () {
if ($this->use_ssl) {
$this->base = "http://api.clickatell.com/http";
$this->base_s = "https://api.clickatell.com/http";
} else {
$this->base = "http://api.clickatell.com/http";
$this->base_s = $this->base;
}

$this->_auth();
}
function _auth() {
$comm = sprintf ("%s/auth?api_id=%s&user=%s&password=%s", $this->base_s, $this->api_id, $this->user, $this->password);
$this->session = $this->_parse_auth ($this->_execgw($comm));
}
function getbalance() {
$comm = sprintf ("%s/getbalance?session_id=%s", $this->base, $this->session);
return $this->_parse_getbalance ($this->_execgw($comm));
}
function send($to=null, $from=null, $text=null) {

if ($this->getbalance() < $this->balace_limit) {
die ("You have reach the SMS credit limit!");
};

/* Check SMS $text length */
if (strlen ($text) > 465) {
die ("Your message is to long! (Current lenght=".strlen ($text).")");
}

/* Does message need to be concatenate */
if (strlen ($text) > 160) {
$concat = "&concat=3";
} else {
$concat = "";
}

/* Check $to and $from is not empty */
if (empty ($to)) {
die ("You not specify destination address (TO)!");
}
if (empty ($from)) {
die ("You not specify source address (FROM)!");
}

/* Reformat $to number */
$cleanup_chr = array ("+", " ", "(", ")", "\r", "\n", "\r\n");
$to = str_replace($cleanup_chr, "", $to);

/* Send SMS now */
$comm = sprintf ("%s/sendmsg?session_id=%s&to=%s&from=%s&text=%s&callba ck=%s%s",
$this->base,
$this->session,
rawurlencode($to),
rawurlencode($from),
rawurlencode($text),
$this->callback,
$concat
);
return $this->_parse_send ($this->_execgw($comm));
}
function _execgw($command) {
if ($this->sending_method == "curl")
return $this->_curl($command);
if ($this->sending_method == "fopen")
return $this->_fopen($command);
die ("Unsupported sending method!");
}
function _curl($command) {
$this->_chk_curl();
$ch = curl_init ($command);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER,0);
if ($this->curl_use_proxy) {
curl_setopt ($ch, CURLOPT_PROXY, $this->curl_proxy);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $this->curl_proxyuserpwd);
}
$result=curl_exec ($ch);
curl_close ($ch);
return $result;
}
function _fopen($command) {
$result = '';
$handler = @fopen ($command, 'r');
if ($handler) {
while ($line = @fgets($handler,1024)) {
$result .= $line;
}
fclose ($handler);
return $result;
} else {
die ("Error while executing fopen sending method!<br>Please check does PHP have OpenSSL support and check does PHP version is greater than 4.3.0.");
}
}
function _parse_auth ($result) {
$session = substr($result, 4);
$code = substr($result, 0, 2);
if ($code!="OK") {
die ("Error in SMS authorization! ($result)");
}
return $session;
}
function _parse_send ($result) {
$code = substr($result, 0, 2);
if ($code!="ID") {
die ("Error sending SMS! ($result)");
} else {
$code = "OK";
}
return $code;
}
function _parse_getbalance ($result) {
$result = substr($result, 8);
return (int)$result;
}
function _chk_curl() {
if (!extension_loaded('curl')) {
die ("This SMS API class can not work without CURL PHP module! Try using fopen sending method.");
}
}
}

?>

Last edited by senraj : 12-27-2007 at 04:04 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-27-2007, 03:59 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: Sending message to mobile using php

This class is meant to send SMS messages via the Clickatell gateway
and provides support to authenticate to this service and also query
for the current account balance. This class use the fopen or CURL module
to communicate with the gateway via HTTP/S.

*For more information about CLICKATELL service visit Clickatell Bulk SMS Gateway
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-27-2007, 10:23 PM
$enthil $enthil is offline
D-Web Sr.Programmer
 
Join Date: Apr 2007
Posts: 162
$enthil is on a distinguished road
Smile Re: Sending message to mobile using php

hi senraj,

we can use clickatell to send SMS but do u know any free SMS gateway to send unlimited free SMS?
__________________
$enthil
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-28-2007, 01:50 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: Sending message to mobile using php

hi,

i think no unlimited free SMS gateway. but Clickatell SMS gateway per day three free SMS.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-02-2008, 12:05 AM
$enthil $enthil is offline
D-Web Sr.Programmer
 
Join Date: Apr 2007
Posts: 162
$enthil is on a distinguished road
Smile Re: Sending message to mobile using php

thanks... but can u suggest me a good cheap SMS gateway?
__________________
$enthil
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sending files from mobile to pc using bluetooth amansundar Mobile Software Development 13 11-13-2007 06:37 AM
Why do I get Error message "Unable to Start Debugging" Error Message? a.deeban ASP and ASP.NET Programming 5 09-25-2007 12:22 AM
Sending SMS through ASP.Net S.Vinothkumar ASP and ASP.NET Programming 12 09-17-2007 05:29 AM
How to convert a SMS message in to Email in Windows mobile? theone Mobile Software Development 1 07-24-2007 11:41 PM
Sending and Receiving values between Flash and .NET(sendAndLoad) oxygen Flash Actionscript Programming 1 07-17-2007 03:10 AM


All times are GMT -7. The time now is 04:57 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0