Join Sprintusers.com Today
By joining our free community you will have access to post topics, communicate privately with other sprint users (PM), download custom made ring tones, use our custom uploader (FOCUS), see LESS forum advertisements, upload photos in your own photo album and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

PDA


View Full Version : sending SMS from website


jhilden
07-28-2005, 10:25 AM
Hi everyone, first off great site, now to my question.

I have a website and I would like to be able to send a text message notification to my cell phone when specific events happen. I don't want to use the email address @sprintpcs.com because I don't have vision so I'd have to pay up the ars.

I found this on another site (may or may not be what I need):
<?php
$content = "<?xml version_";
$len = strlen($content);
$fp = fsockopen( "xml1.aspsms.com", 5061 , &$errno, &$errdesc );
if ( ! $fp ) die ( "Couldn’t connect: $errno $errdesc\n" );
fputs( $fp, "POST /xmlsvr.asp HTTP/1.0\r\n");
fputs( $fp, "Content-Type: text/xml\r\n");
fputs( $fp, "Content-Length: $len\r\n\r\n");
fputs( $fp, $content);
while ( ! feof( $fp ) )
$reply[] = fgets( $fp, 1024 );
fclose( $fp );
?>

So it looks like this is possible but I need to know the address (sms.sprintpcs.com for exampe) and the port number.

Does anyone know of someone who has tried this and has it working? If I get it working I would be happy to share my script with everyone.

Thanks in advance,
Cheers.


donblay
07-28-2005, 01:31 PM
i have some code that i use to run my site that i found at www.sprintdevelopers.com. it was free & open code. i can get you exact link to the thread later for you if you want. it doesn't use the @messaging.sprintpcs.com address, it basically simulates using sprint's text message web page.

jhilden
07-28-2005, 02:41 PM
Donblay, if you could post that link or send me your code that would be awesome!!

donblay
07-29-2005, 05:31 AM
sure, the thread is at http://www.sprintdevelopers.com/postp260.html. This is the code I used to make my site (www.dbringers.info).
The code (by WFrantz) is:

function http($host, $write)
{
$response = '';
$fp = fsockopen($host, 80);
if ($fp)
{
fwrite($fp, $write);
while (! feof($fp))
{
$response .= fgets($fp, 1024);
}
fclose($fp);
}
return($response);
}

function http_post($host, $page, $post)
{
$write = "POST $page HTTP/1.1\r\n" .
"User-Agent: unknown\r\n" .
"Connection: Close\r\n" .
"Host: $host\r\n" .
"Content-Length: " . strlen($post) . "\r\n" .
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Cookie: \$Version=\"1\"; JSESSIONID=\"none\"\r\n" .
"\r\n" .
$post . "\r\n\r\n";

return(http($host, $write));
}

function sendnote($to, $message = '.', $from = '')
{
GLOBAL $track;

$host = 'messagings.sprintpcs.com';
$page = '/textmessaging/composeconfirm';
$post = "phoneNumber=".$to."&message=" . urlencode($message) .
"&callBackNumber=".$from;

$response = http_post($host, $page, $post);

ereg("\?trackNumber=([0-9A-Z]+)", $response, $regs);
$track = $regs[1];

if (stristr($response, "Message sent")) return 0;
if (stristr($response, "not subscribe")) return 2;
if (stristr($response, "Error")) return 3;
return 4;
}

// Example
$result_code = sendnote("8005551111", "Hi there!", "8005552222");

jhilden
07-29-2005, 08:49 AM
donblay you rock!!! It worked first try!! If you lived in Minneapolis I'd buy you a beer.

Here's a dumb question for ya: I don't have vision so I pay per outgoing text message, is there any way that I could/would get charged for sending these to myself?

donblay
07-29-2005, 09:53 AM
donblay you rock!!! It worked first try!! If you lived in Minneapolis I'd buy you a beer.

Here's a dumb question for ya: I don't have vision so I pay per outgoing text message, is there any way that I could/would get charged for sending these to myself?
i'm not positive but i think you get charged for incomeing messages as well. i have unlimited thought, so i'm not sure. anyone else know more definitively?

jhilden
07-29-2005, 11:39 AM
I found this on sprints website when viewing the details of my bill.

Messages Sent & Received - $0.10/msg

Looks like I'm getting charged for both incomming and outgoint, which I think is pretty lame because I can't control who sends me text messages. Maybe I'll call them and complain and see if I can get incomming text for free.

Thanks again for the help.

rrickc
08-24-2005, 06:59 AM
Could someone PLEASE help me? I've created a site using frontpage and I copied the script above so that my friends could send the link to the file directly to their phones with having to download to a PC. But when I click the "submit" button I get an internal server error. So I checked the error logs and premature end of script headers for my "messaging.php" file. The file itself looks like this (again, just copy and paste from www.sprintdevelopers.com):
<?php

function http($host, $write)
{
$response = '';
$fp = fsockopen($host, 80);
if ($fp)
{
fwrite($fp, $write);
while (! feof($fp))
{
$response .= fgets($fp, 1024);
}
fclose($fp);
}
return($response);
}

function http_post($host, $page, $post)
{
$write = "POST $page HTTP/1.1\r\n" .
"User-Agent: unknown\r\n" .
"Connection: Close\r\n" .
"Host: $host\r\n" .
"Content-Length: " . strlen($post) . "\r\n" .
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Cookie: \$Version=\"1\"; JSESSIONID=\"none\"\r\n" .
"\r\n" .
$post . "\r\n\r\n";

return(http($host, $write));
}

function sendnote($to, $message = '.', $from = '')
{
GLOBAL $track;

$host = 'messagings.sprintpcs.com';
$page = '/textmessaging/composeconfirm';
$post = "phoneNumber=".$to."&message=" . urlencode($message) .
"&callBackNumber=".$from;

$response = http_post($host, $page, $post);

ereg("\?trackNumber=([0-9A-Z]+)", $response, $regs);
$track = $regs[1];

if (stristr($response, "Message sent")) return 0;
if (stristr($response, "not subscribe")) return 2;
if (stristr($response, "Error")) return 3;
return 4;
}

// Example
$result_code = sendnote("8005551111", "Hi there!", "8005552222");

?>

Can someone PLEASE help me?

SprintUsers.com was created in January 2002 as a resource for users of Sprint PCS products and services to learn about and share information. We have cll phone reviews, Cellular Accessories, Downloads, PDA reviews, Ringtones, all of the latest Sprint PCS news and information, an area where you can find help in creating a ring tone or custom image for you phone, and so much more. The most popular section is the message board where visitors can read and write messages, ask questions, and get advice about their cellular phone from other users.