PLEAsE HelP -- I need web to sms Script

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

PLEAsE HelP -- I need web to sms Script

Postby aliafzal » Wed Oct 12, 2005 1:16 pm

:) Hello,

if any one have sms sending script via web

like sms2pk.com :?:

please

mail me guy_enjoy@hotmail.com


Ali
aliafzal
Lance Naik
 
Posts: 15
Joined: Mon Jul 04, 2005 10:16 pm
WLM: guy_enjoy@hotmail.com
Yahoo Messenger: no
AOL: no
Location: no

Re: PLEAsE HelP -- I need web to sms Script

Postby phparion » Sat Feb 04, 2006 7:49 am

aliafzal wrote::) Hello,

if any one have sms sending script via web

like sms2pk.com :?:

please

mail me guy_enjoy@hotmail.com


Ali


first of all sms2pk.com is not using its own script to send web2sms but they are using the existing ones from the orginal operators.
The more and more you see and read about how other websites are using SMS, the more and more you begin to wonder why you're not. So I'll show you how (in PHP, because it's the only language i know!). Although it is possible to send SMS via e-mail.
This tutorial focuses on the use of HTTP methods "get" & "post". For those of us that may not know this, using HTTP basically means the use of forms, except that these will be submitted automatically as opposed to manually.

Although this tutorial can be used for any gateway that provides access via HTTP, this tutorial is based on the TM4B Bulk SMS Gateway because:


They are the only gateway I know that have a 'simulation' mode for tweaking your scripts.
- They don't have any set-up fees and their prices are low.
- They are reliable and I use them.

Any SMS gateway will provide details about how you can connect up to them. In the case of TM4B, these are provided on their SMS API page. They basically require us to provide six mandatory pieces of data:

username - our username
password - our password
msg - our SMS message
to - the one or more recipients of our message
from - our sender id
route - the route of the message (i.e. first class or business class)
And we'll add a seventh (optional) one... 'sim' - i.e. simulate.
They will be expecting us to send our messages to them via HTTP requests, similar to this:

http://www.tm4b.com/client/api/send.php?
username=abcdef&password=12345&msg=
This+is+sample+message.&to=447768254545%7C447956219273%
7C447771514662&from=MyCompany&route=frst&sim=yes

which you can test by clicking on it or pasting it into your browser's address bar.

Step 1: Prepare our request
The first step we have to take is to store our data as variables and then convert them into a url request. There are different ways of doing this, but this is a very innovative and useful way borrowed from the TM4B site itself:

<?php

$request = "";

//initialise the request variable

$param[username] = "abcdef";

//this is the username of our TM4B account

$param[password] = "12345";

//this is the password of our TM4B account

$param[msg] = "This is sample message.";

//this is the message that we want to send

$param[to] = "447768254545|447956219273|447771514662";

//these are the recipients of the message

$param[from] = "MyCompany";

//this is our sender if

$param[route] = "frst";

//we want to send the message via first class

$param[sim] = "yes";

//we are only simulating a broadcast

foreach($param as $key=>$val)

//traverse through each member of the param array

{

$request.= $key."=".urlencode($val);

//we have to urlencode the values

$request.= "&";

//append the ampersand (&) sign after each paramter/value pair

}

$request = substr($request, 0, strlen($request)-1);

//remove the final ampersand (&) sign from the request

/*This will produce the following request:username=abcdef&password=12345&
msg=This+is+sample+message.&to=447768254545%7C447956219273%
7C447771514662&from=MyCompany&route=frst&sim=yes */

?>
Step 2: Open up our connection with TM4B and send the request
In step 0, we saw that the request could be actioned by pasting it into the browser window. But what we really want is for this to take place behind the scenes and we wouldn't want anyone knowing our username and password.

The following 2 pieces of code do exactly that. They open up a connection with the gateway, send the SMS message(s) and collect their message ID's which are presented within the response header.

Method 1 : fosckopen method
<?php

//First prepare the info that relates to the connection

$host = "tm4b.com";

//although you can use an ip address, it is easier to just use tm4b.com

$request_length = strlen($request);

// when we post the header, we have to also include it's length

$script = "/client/api/send.php"; $method = "POST";

//Replace with "GET" if required.

if($method=="GET") $script .= "?$request";

//Appends the request if "GET" is being used.

//Now comes the header which we are going to post. This is where our messages details will be sent over.

$header = "$method

$script HTTP/1.1rn".

//"Host: $hostrn". "User-Agent: HTTP/1.1rn". "Content-Type: application/x-www-form-urlencodedrn". "Content-Length: $request_lengthrn". "Connection: closernrn". "$requestrn";

//Now we open up the connection

$socket = @fsockopen($host, 80, $errno, $errstr);

if ($socket) //if its open, then...

{ fputs($socket, $header);

// send the details over

while(!feof($socket)) $output[] = fgets($socket);

//get the results

fclose($socket);

}

//print_r($output);

//the message id's will be kept in one of the $output values

?>
Whilst fsockopen may be more familar to most of us, it can only handle non-secure URL's. Furthermore, difficulty may be experienced when parsing responses for large requests (i.e. hundreds of messages) as the response is transferred in chunks.

Method 2 : Curl method
Whilst "Curl" might sound new, it is a really cool way of connecting and communicate to many different types of servers. You can find more info in the PHP Manual.

Code: Select all

<?php

$url = https://www.tm4b.com/client/api/send.php;


//although we have used https, you can also use http

$ch = curl_init();

//initialize curl handle

curl_setopt($ch, CURLOPT_URL, $url);

//set the url

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

//return as a variable

curl_setopt($ch, CURLOPT_POST, 1);

//set POST method

curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

//set the POST variables

$response = curl_exec($ch);

//run the whole process and return the response

curl_close($ch);

//close the curl handle

//print $response;

//show the result onscreen for debugging

?>


That's It!!! No more. Now you should know how to send one or more SMS messages through an SMS Gateway. By the way, I think Curl is the better, neater and quicker option of the two (assuming your version of PHP supports it) as it can send thousands of messages in one go, gives no problems in parsing the message ID's and uses either a secure or non-secure url.
- Winners never quit, Quitters never win!
phparion
Naik
 
Posts: 51
Joined: Tue Jan 03, 2006 10:36 pm

Re: PLEAsE HelP -- I need web to sms Script

Postby phparion » Sat Feb 04, 2006 7:51 am

aliafzal wrote::) Hello,

if any one have sms sending script via web

like sms2pk.com :?:

please

mail me guy_enjoy@hotmail.com


Ali


first of all sms2pk.com is not using its own script to send web2sms but they are using the existing ones from the orginal operators.
The more and more you see and read about how other websites are using SMS, the more and more you begin to wonder why you're not. So I'll show you how (in PHP, because it's the only language i know!). Although it is possible to send SMS via e-mail.
This tutorial focuses on the use of HTTP methods "get" & "post". For those of us that may not know this, using HTTP basically means the use of forms, except that these will be submitted automatically as opposed to manually.

Although this tutorial can be used for any gateway that provides access via HTTP, this tutorial is based on the TM4B Bulk SMS Gateway because:


They are the only gateway I know that have a 'simulation' mode for tweaking your scripts.
- They don't have any set-up fees and their prices are low.
- They are reliable and I use them.

Any SMS gateway will provide details about how you can connect up to them. In the case of TM4B, these are provided on their SMS API page. They basically require us to provide six mandatory pieces of data:

username - our username
password - our password
msg - our SMS message
to - the one or more recipients of our message
from - our sender id
route - the route of the message (i.e. first class or business class)
And we'll add a seventh (optional) one... 'sim' - i.e. simulate.
They will be expecting us to send our messages to them via HTTP requests, similar to this:

http://www.tm4b.com/client/api/send.php?
username=abcdef&password=12345&msg=
This+is+sample+message.&to=447768254545%7C447956219273%
7C447771514662&from=MyCompany&route=frst&sim=yes

which you can test by clicking on it or pasting it into your browser's address bar.

Step 1: Prepare our request
The first step we have to take is to store our data as variables and then convert them into a url request. There are different ways of doing this, but this is a very innovative and useful way borrowed from the TM4B site itself:

Code: Select all

<?php

$request = "";

//initialise the request variable

$param[username] = "abcdef";

//this is the username of our TM4B account

$param[password] = "12345";

//this is the password of our TM4B account

$param[msg] = "This is sample message.";

//this is the message that we want to send

$param[to] = "447768254545|447956219273|447771514662";

//these are the recipients of the message

$param[from] = "MyCompany";

//this is our sender if

$param[route] = "frst";

//we want to send the message via first class

$param[sim] = "yes";

//we are only simulating a broadcast

foreach($param as $key=>$val)

//traverse through each member of the param array

{

$request.= $key."=".urlencode($val);

//we have to urlencode the values

$request.= "&";

//append the ampersand (&) sign after each paramter/value pair

}

$request = substr($request, 0, strlen($request)-1);

//remove the final ampersand (&) sign from the request

/*This will produce the following request:username=abcdef&password=12345&
msg=This+is+sample+message.&to=447768254545%7C447956219273%
7C447771514662&from=MyCompany&route=frst&sim=yes */

?>


Step 2: Open up our connection with TM4B and send the request
In step 0, we saw that the request could be actioned by pasting it into the browser window. But what we really want is for this to take place behind the scenes and we wouldn't want anyone knowing our username and password.

The following 2 pieces of code do exactly that. They open up a connection with the gateway, send the SMS message(s) and collect their message ID's which are presented within the response header.

Method 1 : fosckopen method

Code: Select all

<?php

//First prepare the info that relates to the connection

$host = "tm4b.com";

//although you can use an ip address, it is easier to just use tm4b.com

$request_length = strlen($request);

// when we post the header, we have to also include it's length

$script = "/client/api/send.php"; $method = "POST";

//Replace with "GET" if required.

if($method=="GET") $script .= "?$request";

//Appends the request if "GET" is being used.

//Now comes the header which we are going to post. This is where our messages details will be sent over.

$header = "$method

$script HTTP/1.1rn".

//"Host: $hostrn". "User-Agent: HTTP/1.1rn". "Content-Type: application/x-www-form-urlencodedrn". "Content-Length: $request_lengthrn". "Connection: closernrn". "$requestrn";

//Now we open up the connection

$socket = @fsockopen($host, 80, $errno, $errstr);

if ($socket) //if its open, then...

{ fputs($socket, $header);

// send the details over

while(!feof($socket)) $output[] = fgets($socket);

     //get the results

    fclose($socket);

}

//print_r($output);

//the message id's will be kept in one of the $output values

?>
Whilst fsockopen may be more familar to most of us, it can only handle non-secure URL's. Furthermore, difficulty may be experienced when parsing responses for large requests (i.e. hundreds of messages) as the response is transferred in chunks.

Method 2 : Curl method
Whilst "Curl" might sound new, it is a really cool way of connecting and communicate to many different types of servers. You can find more info in the PHP Manual.

Code: Select all

<?php

$url = https://www.tm4b.com/client/api/send.php;


//although we have used https, you can also use http

$ch = curl_init();

//initialize curl handle

curl_setopt($ch, CURLOPT_URL, $url);

//set the url

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

//return as a variable

curl_setopt($ch, CURLOPT_POST, 1);

//set POST method

curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

//set the POST variables

$response = curl_exec($ch);

//run the whole process and return the response

curl_close($ch);

//close the curl handle

//print $response;

//show the result onscreen for debugging

?>


That's It!!! No more. Now you should know how to send one or more SMS messages through an SMS Gateway. By the way, I think Curl is the better, neater and quicker option of the two (assuming your version of PHP supports it) as it can send thousands of messages in one go, gives no problems in parsing the message ID's and uses either a secure or non-secure url.
- Winners never quit, Quitters never win!
phparion
Naik
 
Posts: 51
Joined: Tue Jan 03, 2006 10:36 pm

Postby imran4sin » Sat Feb 04, 2006 2:42 pm

phparion, thats excellent work.

I will check it out at some stage.
____
Imran.
<You never know what U can do unless you try>
<work hard, harder untill sweat stings the eye>
imran4sin
Cadet
 
Posts: 10
Joined: Fri Jan 13, 2006 3:07 am
Website: http://au.pg.photos.yahoo.com/ph/netstud69/album?.dir=/f0e6&.src=ph
WLM: imrandman2@hotmail.com
Location: Auckland-NZ ; Islamabad-Pakistan

Postby aliafzal » Fri Feb 10, 2006 12:28 pm

Anyone know how to send SMS on Al warid & Telenor .....

& do tell me the SMS site to send sms to KWT , dubai
aliafzal
Lance Naik
 
Posts: 15
Joined: Mon Jul 04, 2005 10:16 pm
WLM: guy_enjoy@hotmail.com
Yahoo Messenger: no
AOL: no
Location: no

send sms to telenor and alwarid via web2sms

Postby onlywaseem » Thu May 04, 2006 5:04 pm

asala-o-alaikum sms to telenor and alwarid
congratulations! at last i found the site from where you can send sms to telenor and alwarid.........

www.clickatell.com
this is the website...... but a bad news is there that signup is required and each signup contains only 10 credits to send sms......
but DONT WORRY
if anyone want to have unlimited credits..... i have many logins... by which you can send unlimited sms....


for more details........about me........... visit.....www.bingbox.com/onlywaseem
contect:::::: +92-300-7711877
or my e-mail...... onlywaseem@hotmail.com

enjoy!!!!!!!!!!!!!!!!
onlywaseem
Cadet
 
Posts: 1
Joined: Thu May 04, 2006 4:53 pm

Postby phparion » Thu May 04, 2006 5:19 pm

nice but old technique to advertise,,,

there is no need to take so much tensions, just visit warid and telenor official sites and send as many sms as u want :)

though they have a little different way of allowing u to send sms but
if u r not SMS SPAMMER then u should get it easily ..
- Winners never quit, Quitters never win!
phparion
Naik
 
Posts: 51
Joined: Tue Jan 03, 2006 10:36 pm

Postby lambda » Thu May 04, 2006 6:55 pm

i can't find any way to send an sms through telenor's site. what's the url to their form?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby masud » Mon May 15, 2006 12:12 pm

lambda wrote:i can't find any way to send an sms through telenor's site. what's the url to their form?


Ahhh! I'm Waitting for it as well :)

Masood
--SP--
masud
Havaldaar
 
Posts: 108
Joined: Thu Aug 05, 2004 12:15 am
Website: http://fedoraproject.org/wiki/MasoodMehmood
WLM: silentplayer@internet-criminals.com
Yahoo Messenger: xlx_silentplayer_xlx
Location: Fremont, CA


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron