PennyTel SMS

From KlavoWiki
Jump to navigationJump to search

Using the PennyTel API and a custom made html and PHP web pages you can send SMS to anyone world wide. Using the PennyTel account and configuring a CID you can send the SMS with the recipient believing it was sent from you mobile. Anyone replying to a SMS will be sent to your mobile.

HTM Page

<html>

<head>
<meta http-equiv="Content-Language" content="en-au">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Klaverstyn SMS portal</title>
</head>

<body>

<form method="POST" action="sms.php">

	<table border="0" width="300" cellspacing="0" cellpadding="0">
		<tr>
			<td align="center" width="33%">
			<font color="#FF0000">SMS</font></td>
			<td align="center" width="33%"><a href="p2p.htm">P2P</a></td>
			<td align="center" width="33%"><a href="call-back.htm">Call-Back</a></td>
		</tr>
	</table>


        <table border="0" cellspacing="0" cellpadding="0" width="300">
                        <tr>
                                <td colspan="4"><b>SMS</b> (Short Message 
								Service)</td>
                        </tr>
                        <tr>
                                <td align="right">Source</td>
                                <td width="15"> </td>
                                <td colspan="2"><select size="1" name="Sender">
								<option selected>Lee</option>
								<option>David</option>
								</select></td>
                        </tr>
                        <tr>
                                <td align="right">Number</td>
                                <td width="15"> </td>
                                <td colspan="2">
								<!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" B-Value-Required="TRUE" I-Minimum-Length="10" I-Maximum-Length="10" -->
								<input type="text" name="Phone_Number" size="10" maxlength="10" value="04"></td>
                        </tr>
                        <tr>
                                <td align="right" valign="top">Message</td>
                                <td> </td>
                                <td colspan="2"><textarea rows="6" name="Message" cols="26"></textarea></td>
                        </tr>
                        <tr>
                                <td align="right"> </td>
                                <td> </td>
                                <td colspan="2"> </td>
                        </tr>
                        <tr>
                                <td align="right">
								 </td>
                                <td> </td>
                                <td>
								<input type="submit" value="Submit" name="Submit"></td>
                                <td>
								<input type="reset" value="Reset" name="Reset"></td>
                        </tr>
                </table>
</form>

</body>
</html>

PHP File

<?php

	/*	PennyTel SMS Appliction
		Written by David Klaverstyn
		Started	: 19th January 2009
		Last Update	: 
	*/

	header("Refresh: 5; url=sms.htm");
	
	require_once('lib/nusoap.php');
	$Send_Time = "2000-01-01T00:00:00";
	
	// Account Details and Log file to use
	if ($_POST[Sender] == 'Lee')
		{
			$logfile = "lee.klaverstyn.csv";
			$Account_ID = "username";
			$Account_PW = "password";
		}
		elseif ($_POST[Sender] == 'David')
		{
			$logfile = "david.klaverstyn.csv";
			$Account_ID = "username";
			$Account_PW = "password";
		}
	
	$Write_Log = true;						// Write to log file?
	$Actual_Dest = '61' . substr($_POST[Phone_Number],1,9);		// Destined phone number for SMS message
	$the_message = $_POST[Message];					// SMS Message

	$client = new nusoap_client("http://pennytel.com/pennytelapi/services/PennyTelAPI");

	$err = $client->getError();
	if ($err)
		{
			echo '<h2>Constructor error</h2><pre>' . $err . '</ pre>';
		}

	function Send_the_SMS()
		{
			global	$client, $body, $the_message, $Account_ID, $Account_PW,
					$Actual_Dest, $Send_Time, $logfile;

			// Send SMS
			$param = array
				(
					'ID'		=> $Account_ID,
					'Password'	=> $Account_PW,
					'Type'		=> 1,													// $SMS_Type  0 = free		1 = Premium
					'To'		=> $Actual_Dest,
					'Message'	=> $the_message,
					'Date'		=> new soapval('Date', 'dateTime', $Send_Time)
				);
			$result = $client->call('sendSMS', $param);									// Send!

			if ($client->fault)
				{
					echo '<h2>Fault</h2><pre>'; print_r($result); echo '</ pre>';
				} 
			else
				{
					$err = $client->getError();
					if ($err) 
						{
							echo '<h2>Error</h2><pre>' . $err . '</ pre>';
						} else 
							{							
								print "Message Sent<br>";
								if (Write_Log)
									{
										$fp=fopen($logfile, 'a'); // Write to file name.
										fwrite($fp, $Parse_Type.",\"".$Actual_Dest."\",SENT,\"".$Time_Now."\",\"".$Original_Subject."\",\"".$fromname."\",\"".$fromaddress."\"\r\n"); 
										fclose($fp);
									}
							}  // else
				} // if fault
		} // Send_the_SMS


		Send_the_SMS();
		
	print 'You will be redirect in 5 seconds.';

?>