Ciao a tutti :-)
Ho attivato un servizio di invio sms (per ora utilizzando il client email).
Avendo a disposizione un server web (su linux - apache) vorrei poter inviare gli sms attraverso il sito, quindi implementare lo script in una pagina per inviare gli sms.
Essendo a digiuno di php chiedo a voi se in base allo script che il servizio rende disponibile e' fattibile (su debian c'e' php4)
Qui' sotto lo script.
Grazie per l'aiuto :-)
Pol
-- inizio script ---
<?
//-------------------------------------------------------------------------------------------
// PHP SCRIPT FOR SMS GATEWAY
// (c) 2001-2007 Digitel Mobile Srl
// all rights reserved
// last update: 30 January 2007
//-------------------------------------------------------------------------------------------
// +OK Credit SMS accepted by SMS Server. It return the credit charged and SMS numbers ready to deliver.
// -ERR 100 Syntax/System Error
// -ERR 99 Credit Not Available
// -ERR 98 Login Failure
// -ERR 97 Gateway Error
// -ERR 96 Country Code Not Valid
// -ERR 95 Gsm Code Not Valid
// -ERR 94 Phone Number/Recipients Not Valid
// -ERR 93 SMS Data Not Valid
// -ERR 92 Data/Time Not Valid
// -ERR 91 Country Code or/and Gsm Code Not Available
// -ERR 90 Network Barred
// -ERR 89 Account Blocked
// -ERR 88 SMS Not Recognized
// -ERR 87 IP Address Blocked By Account
// -ERR 86 Recipient Blocked By Account
// -ERR 85 IP Address Not Authorized
// -ERR 84 Sender Not Valid
// -ERR 83 Bad Request
$Account = "xxxxxxxxx"; // Mandatory Max 20 Bytes String Username of customer account
$Password = "yyyyyyyy"; // Mandatory Max 20 Bytes String Password of customer account
$Sender = "testSMS"; // Mandatory Max 16 Digits or 11 characters alpahnumeric Originator
$Recipients = 2; // Mandatory Max 2 Digits Integer: 1 to 99 Number of recipients to which sending
$PhoneNumbers = "+39123456789,+44123456789"; // Mandatory Max 16384 Bytes List of one or several recipient phone number to receive the SMS (separated by commas)
$SMSData = "This is a test message"; // Mandatory Max 4096 Bytes String SMS Message
$SMSType = ""; // Optional Max 3 Bytes String Type of message
$SMSDateTime = "25-Dec-2007 02:00:00 PM"; // Optional Max 30 Bytes Date and Time Desired deferred delivery date and time
$SMSTest = True; // Optional Boolean (True or False) Indicates "test" mode
$SMSGateway = ""; // Optional Max 1 Digit Integer Routing specification
$NetworkCode = ""; // Optional Max 6 Bytes Hex Network code specification
$UDH = ""; // Optional Max 400 Bytes STRING User Data Header
$DCS = ""; // Optional Max 2 Bytes Hex Data Coding Scheme
$DeliveryRequest = 1; // Optional Max 1 Digit Integer Delivery request on GSM (check the networks available)
$Notification = "mailto:youremail@yourdomain.xxx"; // Optional Max 98 Bytes String Allow to send notification to email address or towards a script via Http
$SmsValidity = ""; // Optional Max 4 Digits Numeric Validity Period
$SmsRef = "1000012345"; // Optional Max 20 Bytes String User Id Reference
$Account = urlencode($Account);
$Password = urlencode($Password);
$Sender = urlencode($Sender);
$PhoneNumbers = urlencode($PhoneNumbers);
$SMSData = urlencode($SMSData);
$SMSDateTime = urlencode($SMSDateTime);
$UDH = urlencode($UDH);
$Notification = urlencode($Notification);
$SmsRef = urlencode($SmsRef);
//-------------------------------------------------------------------------------------------
// BUILDS THE STRING TO SEND TO THE SERVER
//-------------------------------------------------------------------------------------------
$StringHttpPost="Account=".$Account."&Password=".$ Password."&SMSTest=".$SMSTest."&SMSGateway=".$SMSG ateway."&Recipients=".$Recipients."&PhoneNumbers=" .$PhoneNumbers."&Sender=".$Sender."&SMSData=".$SMS Data;
$StringHttpPost=$StringHttpPost."&SMSDateTime=".$S MSDateTime."&SMSType=".$SMSType."&NetworkCode=".$N etworkCode."&Udh=".$Udh;
$StringHttpPost=$StringHttpPost."&DeliveryRequest= ".$DeliveryRequest."&Notification=".$Notificat ion;
$StringHttpPost=$StringHttpPost."&SmsValidity=".$S msValidity."&SmsRef=".$SmsRef."&DCS=".$DCS;
$len = strlen($StringHttpPost);
//---------------------------------------
// IF USE PROXY
//---------------------------------------
//$p = "POST http://gateway.smsitaly.com/bulk/send.asp HTTP/1.0\r\n"; // Use This String
//---------------------------------------
// IF DIRECT CONNTECTION
//---------------------------------------
$p = "POST /bulk/send.asp HTTP/1.0\r\n"; // Use This String
$p.= "Host: gateway.smsitaly.com\r\n";
$p.= "Content-type: application/x-www-form-urlencoded\r\n";
$p.= "Content-length: $len\r\n\r\n";
$p.= "$StringHttpPost\r\n";
$p.= "\r\n";
//---------------------------------------
// IF USE PROXY
//---------------------------------------
//$ip = "1.2.3.4"; // IP Proxy
//$port = 1234; // Porta Proxy
//$fp = fsockopen($ip,$port); // Use This String
$fp = fsockopen ("gateway.smsitaly.com", 80, &$errno, &$errstr, 30);
//----------------------------------------
// GIVES THE RESPONSE FOR THE SENT MESSAGE
//----------------------------------------
if ($fp) {
fputs ($fp,$p);
$rawreply = fread ($fp,1024);
fclose($fp);
$replyarray = explode ("\n", $rawreply);
$result_a = $replyarray[11];
$result_b = $replyarray[12];
$result_c = $replyarray[13]; }
else
{
$result_a = "Connection Error!!";
$result_b = "";
$result_c = "";
}
print $result_a;
print $result_b;
print $result_c;
?>
-- fine script --