160 || strlen($message) == 0) return 1; $post = 'randomToken=&' . 'phoneNumber=' . $to . '&message=' . urlencode($message) . '&characters=' . (160 - strlen($message)) . '&callBackNumber=' . $from . '&x=0&y=0'; $post_len = strlen($post); $Host = 'messaging.sprintpcs.com'; $fp = fsockopen($Host, 80); if ($fp) { $Page = '/textmessaging/composeconfirm'; fwrite($fp, "POST $Page HTTP/1.1\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; rv:1.7.3) Gecko/20040913 Firefox/0.10.1\r\n" . "Host: $Host\r\n" . "Pragma: no-cache\r\n" . "Accept: image/gif, image/x-xbitmap, image/jpeg, " . "image/pjpeg, */*\r\n" . "Content-Length: " . $post_len . "\r\n" . "Content-Type: application/x-www-form-urlencoded\r\n" . "Connection: Close\r\n" . "Cookie: \$Version=\"1\"; JSESSIONID_JFS=\"none\"\r\n" . "\r\n" . $post . "\r\n\r\n"); $response = ''; while (! feof($fp)) { $response .= fgets($fp, 1024); } fclose($fp); if (preg_match("/\\?trackNumber=([0-9A-Z]+)/", $response, $regs)) $GLOBALS['trackNumber'] = $regs[1]; if ($debug) echo "
" . nl2br(str_replace("\r\n", "\n",
htmlspecialchars($response)))
. "\n\n";
if (stristr($response, "Message sent"))
return 0;
if (stristr($response, "not subscribe"))
return 2;
if (stristr($response, "Error"))
return 3;
return 4;
}
return 5;
}
// Returns a text string describing the return code from SendSprintSMS()
function SprintErrorDesc($err)
{
$Codes = array(0 => 'Message sent successfully.',
1 => 'Error with parameters calling SendSprintSMS(). ' .
'$to must have 10 digits, $message must be 160 ' .
'chars or less, $from must be an empty string or ' .
'contain 10 digits.',
2 => 'Sprint\'s web site returned "not subscribed" error.',
3 => 'Sprint\'s web site returned "Error".',
4 => 'The status could not be parsed properly from ' .
'Sprint\'s web site.',
5 => 'Sprint\'s messaging site appears to be down.',
);
if (isset($Codes[$err]))
return $Codes[$err];
return 'Unhandled error code. [' . $err . ']';
}