Contacts   0039 02 40 70 72 40
EN IT flag-down
FREE SIGN UP         LOGIN

Code Examples

Here you can copy and paste code examples for our APIs and get ready to start sending SMS immediately!

Send SMS examples

Below you'll find a selection of examples that you can copy and modify as needed. If you require help, contact us
Copy to clipboard


  • <?php
    define("NET_ERROR", "Network+error,+unable+to+send+the+message");
    define("SENDER_ERROR", "You+can+specify+only+one+type+of+sender,+numeric+or+alphanumeric");
    
    define ("SMS_TYPE_CLASSIC", "classic");
    define ("SMS_TYPE_CLASSIC_PLUS", "classic_plus");
    define ("SMS_TYPE_BASIC", "basic");
    define ("SMS_TYPE_TEST_CLASSIC", "test_classic");
    define ("SMS_TYPE_TEST_CLASSIC_PLUS", "test_classic_plus");
    define ("SMS_TYPE_TEST_BASIC", "test_basic");
    
    
    function do_post_request($url, $data, $optional_headers = null){
    	if(!function_exists('curl_init')) {
    		$params = array(
    			'http' => array(
    				'method' => 'POST',
    				'content' => $data
    			)
    		);
    		if ($optional_headers !== null) {
    			$params['http']['header'] = $optional_headers;
    		}
    		$ctx = stream_context_create($params);
    		$fp = @fopen($url, 'rb', false, $ctx);
    		if (!$fp) {
    			return 'status=failed&message='.NET_ERROR;
    		}
    		$response = @stream_get_contents($fp);
    		if ($response === false) {
    			return 'status=failed&message='.NET_ERROR;
    		}
    		return $response;
    	} else {
    		$ch = curl_init();
    		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
    		curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    		curl_setopt($ch,CURLOPT_TIMEOUT,60);
    		curl_setopt($ch,CURLOPT_USERAGENT,'Generic Client');
    		curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
    		curl_setopt($ch,CURLOPT_URL,$url);
    
    		if ($optional_headers !== null) {
    			curl_setopt($ch,CURLOPT_HTTPHEADER,$optional_headers);
    		}
    
    		$response = curl_exec($ch);
    		curl_close($ch);
    		if(!$response){
    			return 'status=failed&message='.NET_ERROR;
    		}
    		return $response;
    	}
    }
    
    function skebbyGatewaySendSMS($username,$password,$recipients,$text,$sms_type=SMS_TYPE_CLASSIC,$sender_number='',$sender_string='',$user_reference='',$charset='',$optional_headers=null) {
    	$url = 'http://gateway.skebby.it/api/send/smseasy/advanced/http.php';
    
    	if (!is_array($recipients)){
    		$recipients = array($recipients);
    	}
    
    	switch($sms_type) {
    		case SMS_TYPE_CLASSIC:
    		default:
    			$method='send_sms_classic';
    			break;
    		case SMS_TYPE_CLASSIC_PLUS:
    			$method='send_sms_classic_report';
    			break;
    		case SMS_TYPE_BASIC:
    			$method='send_sms_basic';
    			break;
    		case SMS_TYPE_TEST_CLASSIC:
    			$method='test_send_sms_classic';
    			break;
    		case SMS_TYPE_TEST_CLASSIC_PLUS:
    			$method='test_send_sms_classic_report';
    			break;
    		case SMS_TYPE_TEST_BASIC:
    			$method='test_send_sms_basic';
    			break;
       }
    
    	$parameters = 'method='
    				  .urlencode($method).'&'
    				  .'username='
    				  .urlencode($username).'&'
    				  .'password='
    				  .urlencode($password).'&'
    				  .'text='
    				  .urlencode($text).'&'
    				  .'recipients[]='.implode('&recipients[]=',$recipients)
    				  ;
    				  
    	if($sender_number != '' && $sender_string != '') {
    		parse_str('status=failed&message='.SENDER_ERROR,$result);
    		return $result;
    	}
    	$parameters .= $sender_number != '' ? '&sender_number='.urlencode($sender_number) : '';
    	$parameters .= $sender_string != '' ? '&sender_string='.urlencode($sender_string) : '';
    
    	$parameters .= $user_reference != '' ? '&user_reference='.urlencode($user_reference) : '';
    
    	
    	switch($charset) {
    		case 'UTF-8':
    			$parameters .= '&charset='.urlencode('UTF-8');
                break;
    		case '':
    		case 'ISO-8859-1':
    		default:
                break;
    	}
    	
    	parse_str(do_post_request($url,$parameters,$optional_headers),$result);
    
    	return $result;
    }
    
    function skebbyGatewayGetCredit($username,$password,$charset=''){
    	$url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php";
    	$method = "get_credit";
    	
    	$parameters = 'method='
    				.urlencode($method).'&'
                    .'username='
                    .urlencode($username).'&'
                    .'password='
                    .urlencode($password);
    				
    	switch($charset) {
    		case 'UTF-8':
    			$parameters .= '&charset='.urlencode('UTF-8');
    			break;
    		default:
    	}
    	
    	parse_str(do_post_request($url,$parameters),$result);
    	return $result;
    }
    
    // Single dispatch
    $recipients = array('393471234567');
    
    // Multiple dispatch
    // $recipients = array('393471234567','393497654321');
    
    
    // ------------ SMS Classic dispatch --------------
    
    // SMS CLASSIC dispatch with custom alphanumeric sender
     $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_CLASSIC,'','John');
    
    // SMS CLASSIC dispatch with custom numeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_CLASSIC,'393471234567');
    
    
    // ------------- SMS Basic dispatch ----------------
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you? By John', SMS_TYPE_BASIC);
    
    
    // ------------ SMS Classic Plus dispatch -----------
    
    // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_CLASSIC_PLUS,'','John');
    
    // SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_CLASSIC_PLUS,'393471234567');
    
    // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender and custom reference string
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_CLASSIC_PLUS,'393471234567','','reference');
    
    
    
    
    //  ------------------------------------------------------------------
    //     WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS 
    //     USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
    //  ------------------------------------------------------------------
    
    // ------------- SMS Classic test dispatch ---------
    // SMS CLASSIC test dispatch with custom alphanumeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_TEST_CLASSIC,'','John');
    
    // SMS CLASSIC test dispatch with custom numeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_TEST_CLASSIC,'393471234567');
    
    // ------------ SMS Classic Plus test dispatch -----------
    
    // SMS CLASSIC PLUS test dispatch (with delivery report) with custom alphanumeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_TEST_CLASSIC_PLUS,'','John');
    
    // SMS CLASSIC PLUS test dispatch (with delivery report) with custom numeric sender
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you?', SMS_TYPE_TEST_CLASSIC_PLUS,'393471234567');
    
    // ------------- SMS Basic test dispatch ----------------
    // $result = skebbyGatewaySendSMS('username','password',$recipients,'Hi Mike, how are you? By John', SMS_TYPE_TEST_BASIC);
    
    // ------------------------------------------------------------------
    //    WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS
    //    USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
    // ------------------------------------------------------------------
    
    
    if($result['status']=='success') {
    	echo '<b style="color:#8dc63f;">Message Sent!</b><br/>';
    	if (isset($result['remaining_sms'])){
    		echo '<b>Remaining SMS:</b> '.$result['remaining_sms'];
    	}
    	if (isset($result['id'])){
    		echo '<b>ID:</b> '.$result['id'];
    	}
    }
    
    // ------------------------------------------------------------------
    // Check the complete documentation at http://www.skebby.com/business/index/send-docs/
    // ------------------------------------------------------------------
    // For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    // WARNING: in case of error DON'T retry the sending, since they are blocking errors
    // ------------------------------------------------------------------
    if($result['status']=='failed')	{
    	echo '<b style="color:#ed1c24;">Sending failed</b><br/>';
    	if(isset($result['code'])) {
    		echo '<b>Code:</b> '.$result['code'].'<br/>';
    	}
    		echo '<b>Description:</b> '.urldecode($result['message']);
    }
    
    
    // ------------ REMAINING CREDIT Check -------------
    // $credit_result = skebbyGatewayGetCredit('username', 'password');
    
    
    //if($credit_result['status']=='success') {
    //	echo 'Current Balance: ' .$credit_result['credit_left']."\n";
    //	echo 'Remaining SMS Classic: ' .$credit_result['classic_sms']."\n";
    //	echo 'Remaining SMS Basic: ' .$credit_result['basic_sms']."\n";
    //}
    
    //if($credit_result['status']=='failed') {
    //	echo 'Sending request failed';
    //}
    
    ?>					

  • <%
    Const SENDER_ERROR="You can specify only one type of sender, numeric or alphanumeric"
    
    function skebbyGatewaySendSMS(username,password,recipients,text,sms_type,sender_number,sender_string,charset)
    	url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
    	method = ""
    	select case sms_type
    		case "classic"
    			method = "send_sms_classic"
    		case "report"
    			method = "send_sms_classic_report"
    		case else
    			method = "send_sms_basic"
    	end select
    
    	parameters = "method=" & Server.urlencode(method) & "&" _
    				& "username=" & Server.urlencode(username) & "&" _
    				& "password=" & Server.urlencode(password) & "&" _
    				& "text=" & Server.urlencode(text) & "&" _
    				& "recipients[]=" & join(recipients,"&recipients[]=")
    
    	if sender_number <> "" And sender_string <> "" then
    		skebbyGatewaySendSMS = "status=failed&message=" & SENDER_ERROR
    		exit function
    	end if
    
    	if sender_number <> "" then parameters = parameters & "&sender_number=" & Server.urlencode(sender_number)
    	if sender_string <> "" then parameters = parameters & "&sender_string=" & Server.urlencode(sender_string)
    
    	select case charset
    		case "UTF-8"
    			parameters = parameters & "&charset=" & Server.urlencode("UTF-8")
    		case else
    	end select
    
    	set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
    	xmlhttp.open "POST", url, false
    	xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    	xmlhttp.setRequestHeader "Content-Length", Len(parameters)
    	xmlhttp.Send parameters 
    
    	If xmlhttp.Status >= 400 And xmlhttp.Status <= 599 Then
    		skebbyGatewaySendSMS = "status=failed&message=" & xmlhttp.Status & " - " & xmlhttp.statusText
    		exit function
    	End If
    
    	msg = xmlhttp.responseText
    	set xmlhttp = nothing
    
    	skebbyGatewaySendSMS = msg
    end function
    
    Dim recipients
    Dim i
    
    ' Single dispatch
    recipients = array("393471234567")
    
    ' Multiple dispatch
    ' recipients = array("393471234567","393497654321")
    
    ' ------------------------------------------------------------------
    ' Check the complete documentation at http:#www.skebby.com/business/index/send-docs/ 
    ' ------------------------------------------------------------------
    ' For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    ' WARNING: in case of error DON'T retry the sending, since they are blocking errors
    ' ------------------------------------------------------------------	
    
    ' SMS CLASSIC dispatch with custom alphanumeric sender
    result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?","classic","","John","")
    
    ' SMS Basic dispatch
    ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?","basic","","","")
    
    ' SMS CLASSIC dispatch with custom numeric sender
    ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?","classic","393471234567","","")
    
    ' SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?","report","","John","")
    
    ' SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?","report","393471234567","","")
    
    responses = split(result,"&")
    
    for each item in responses
    	Response.write item & "<br/>"
    next
    
    %>					

  • Const SMS_TYPE_CLASSIC As String = "classic"
    Const SMS_TYPE_CLASSIC_PLUS As String = "classic_plus"
    Const SMS_TYPE_BASIC As String = "basic"
    Const SMS_TYPE_TEST_CLASSIC As String = "test_classic"
    Const SMS_TYPE_TEST_CLASSIC_PLUS As String = "test_classic_plus"
    Const SMS_TYPE_TEST_BASIC As String = "test_basic"
    
    Function URLEncode(ByVal Text As String) As String
    
    	Dim i As Integer
    	Dim acode As Integer
    	Dim chr As String
    	Dim hexValue As String
    	Dim finalString As String
    
    	finalString = ""
    
    	For i = 1 To Len(Text) Step 1
    		acode = Asc(Mid$(Text, i, 1))
    		Select Case acode
    			Case 48 To 57, 65 To 90, 97 To 122
    				' don't touch alphanumeric chars
    				finalString = finalString & Mid$(Text, i, 1)
    			Case 32
    				' replace space with "+"
    				'Mid$(Text, i, 1) = "+"
    				finalString = finalString & "+"
    			Case Else
    				hexValue = Hex$(acode)
    				Select Case Len(hexValue)
    					Case 1
    						hexValue = "0" & hexValue
    					Case 2
    						'ok
    					Case Else
    						'carattere non valido
    						'skip
    						hexValue = ""
    				End Select
    				
    				' replace punctuation chars with "%hex"
    				finalString = finalString & "%" & hexValue
    
    
    		End Select
    	Next
    	URLEncode = finalString
    End Function
    
    
    Function skebbyGatewaySendSMS(username As String, password As String, recipients() As String, Text As String, sms_type As String, Optional sender_number As String = "", Optional sender_string As String = "", Optional user_reference As String = "", Optional charset As String = "") As String
    	Dim sender_error, url, method, parameters, msg As String
    
    	Dim xmlhttp As Object
    	Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    
    
    	url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
    	sender_error = "You can specify only one type of sender, numeric or alphanumeric"
    	method = "send_sms_classic"
    
    	Select Case sms_type
    		Case SMS_TYPE_CLASSIC
    			method = "send_sms_classic"
    		Case SMS_TYPE_CLASSIC_PLUS
    			method = "send_sms_classic_report"
    		Case SMS_TYPE_BASIC
    			method = "send_sms_basic"
    		Case SMS_TYPE_TEST_CLASSIC
    			method = "test_send_sms_classic"
    		Case SMS_TYPE_TEST_CLASSIC_PLUS
    			method = "test_send_sms_classic_report"
    		Case SMS_TYPE_TEST_BASIC
    			method = "test_send_sms_basic"
    		Case Else
    			method = "send_sms_classic"
    	End Select
    
    	parameters = "method=" & method & "&" _
    				 & "username=" & URLEncode(username) & "&" _
    				 & "password=" & URLEncode(password) & "&" _
    				 & "text=" & URLEncode(Text) & "&" _
    				 & "recipients[]=" & Join(recipients, "&recipients[]=")
    
    	If sender_number <> "" And sender_string <> "" Then
    		skebbyGatewaySendSMS = "status=failed&message=" & sender_error
    		Exit Function
    	End If
    
    	If sender_number <> "" Then parameters = parameters & "&sender_number=" & URLEncode(sender_number)
    	If sender_string <> "" Then parameters = parameters & "&sender_string=" & URLEncode(sender_string)
    
    	If user_reference <> "" Then parameters = parameters & "&user_reference=" & URLEncode(user_reference)
    
    	Select Case charset
    		Case "UTF-8"
    			parameters = parameters & "&charset=UTF-8"
    		Case Else
    	End Select
    
    
    
    	xmlhttp.open "POST", url, False
    	xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    	xmlhttp.setRequestHeader "Content-Length", Len(parameters)
    	xmlhttp.Send (parameters)
    
    	If xmlhttp.Status >= 400 And xmlhttp.Status <= 599 Then
    		skebbyGatewaySendSMS = "status=failed&message=" & xmlhttp.Status & " - " & xmlhttp.statusText
    		Exit Function
    	End If
    
    	' ------------------------------------------------------------------
    	' Check the complete documentation at http:#www.skebby.com/business/index/send-docs/ 
    	' ------------------------------------------------------------------
    	' For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    	' WARNING: in case of error DON'T retry the sending, since they are blocking errors
    	' ------------------------------------------------------------------    
    
    	msg = xmlhttp.responseText
    	Set xmlhttp = Nothing
    
    	skebbyGatewaySendSMS = msg
    
    End Function
    
    Function skebbyGatewayGetCredit(username As String, password As String, Optional charset As String = "") As String
    	Dim url, method, parameters, msg As String
    	Dim xmlhttp As Object
    	Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    
    	url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
    	method = "get_credit"
    
    	parameters = "method=" & method & "&" _
    				 & "username=" & URLEncode(username) & "&" _
    				 & "password=" & URLEncode(password)
    
    	Select Case charset
    		Case "UTF-8"
    			parameters = parameters & "&charset=UTF-8"
    		Case Else
    	End Select
    
    
    
    	xmlhttp.open "POST", url, False
    	xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    	xmlhttp.setRequestHeader "Content-Length", Len(parameters)
    	xmlhttp.Send (parameters)
    
    	If xmlhttp.Status >= 400 And xmlhttp.Status <= 599 Then
    		skebbyGatewayGetCredit = "status=failed&message=" & xmlhttp.Status & " - " & xmlhttp.statusText
    		Exit Function
    	End If
    
    	msg = xmlhttp.responseText
    	Set xmlhttp = Nothing
    
    	skebbyGatewayGetCredit = msg
    
    End Function
    
    
    Private Sub Form_Load()
    
    	Dim recipients(0) As String
    	Dim i As Integer
    
    	' Single dispatch
    	recipients(0) = "393471234567"
    
    	' Multiple dispatch
    	' recipients(0) = "393471234567"
    	' recipients(1) = "393497654321"
    
    	' ------------ SMS Classic dispatch --------------
    
        ' SMS CLASSIC dispatch with custom alphanumeric sender
    	Dim result As String
    	result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC,"","John")
    
    	' SMS CLASSIC dispatch with custom numeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC,"393471234567")
    
    
    	' ------------- SMS Basic dispatch ----------------
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you? By John", SMS_TYPE_BASIC)
    
    
    	' ------------ SMS Classic Plus dispatch -----------
    
    	' SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"","John")
    
    	' SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"393471234567")
    
    	' SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender and custom reference string
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"393471234567","","reference")
    
    
    
    	' ------------------------------------------------------------------
        '     WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS 
        '     USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
        ' ------------------------------------------------------------------
    
    	' ------------- SMS Classic test dispatch ---------
    
    	' SMS CLASSIC test dispatch with custom alphanumeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC,"","John")
    
    	' SMS CLASSIC test dispatch with custom numeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC,"393471234567")
    
    
    	' ------------- SMS Classic Plus test dispatch ---------
    
    	' SMS CLASSIC PLUS test dispatch (with delivery report) with custom alphanumeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"","John")
    
    	' SMS CLASSIC PLUS test dispatch (with delivery report) with custom numeric sender
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"393471234567")
    
    
    	' ------------- SMS Basic test dispatch ---------------
    	' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you? By John", SMS_TYPE_TEST_BASIC)
    
    
    	' ------------ REMAINING CREDIT Check -------------
    	' result = skebbyGatewayGetCredit("username", "password")
    
    	Dim responses As String()
    	responses = Split(result, "&")
    	Dim Response As String = ""
    	For Each Item In responses
    		Response = Response & Item & vbCrLf
    	Next
    	
    	Dim msg As Integer
    	msg = MsgBox(Response, vbOKOnly + vbInformation, "Result")
    	
    End Sub					

  • using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using System.Net;
    using System.IO;
    using System.Web;
    
    
    namespace ConsoleApplication1
    {
        class Program
        {
    
            public const string SMS_TYPE_CLASSIC = "classic";
            public const string SMS_TYPE_CLASSIC_PLUS = "classic_plus";
            public const string SMS_TYPE_BASIC = "basic";
            public const string SMS_TYPE_TEST_CLASSIC = "test_classic";
            public const string SMS_TYPE_TEST_CLASSIC_PLUS = "test_classic_plus";
            public const string SMS_TYPE_TEST_BASIC = "test_basic";
    
    
            static void Main(string[] args)
            {
                // Single dispatch
                String[] recipients = new String[] { "393471234567" };
    
                // Multiple dispatch
                // String[] recipients = new String[] { "393471234567", "393477654321" };
    
                Hashtable result = new Hashtable();
                Hashtable credit_result = new Hashtable();
                String line;
    
                // ------------ SMS Classic dispatch --------------
    
                // SMS CLASSIC dispatch with custom alphanumeric sender
                   result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_CLASSIC, "", "John","","");
    
                // SMS CLASSIC dispatch with custom numeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC,"393471234567","","","");
    
                // ------------ SMS Basic dispatch --------------
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you? By John", SMS_TYPE_BASIC, "", "","","");
    
                // ------------ SMS Classic Plus dispatch --------------
    
                // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"","John","","");
    
                // SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"393471234567","","","");
    
                // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender and custom reference string
                // result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS, "393471234567", "", "riferimento", "");
    
    
                //  ------------------------------------------------------------------
    			//     WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS 
    			//     USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
    			//  ------------------------------------------------------------------
    
                // ------------- SMS Classic test dispatch ---------
    
                // SMS CLASSIC test dispatch with custom alphanumeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC,"","John","","");
    
                // SMS CLASSIC test dispatch with custom numeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC,"393471234567","","","");
    
    
                // ------------ SMS Classic Plus test dispatch -----------
    
                // SMS CLASSIC PLUS test dispatch (with delivery report) with custom alphanumeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"","John","","");
    
                // SMS CLASSIC PLUS test dispatch (with delivery report) with custom numeric sender
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"393471234567","","","");
    
                // ------------- SMS Basic test dispatch ----------------
                // result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you? By John", SMS_TYPE_TEST_BASIC,"","","","");
    
                if ((string)result["status"] == "success")
                {
                    Console.WriteLine("Message Sent!");
                    Console.WriteLine("Remaining SMS: " + result["remaining_sms"]);
    
                    if (result.ContainsKey("id"))
                    {
                        Console.WriteLine("ID: " + result["id"]);
                    }
    
                }
    			
    			// ------------------------------------------------------------------
    			// Controlla la documentazione completa all'indirizzo http://www.skebby.it/business/index/send-docs/ 
    			// ------------------------------------------------------------------
    			// Per i possibili errori si veda http://www.skebby.it/business/index/send-docs/#errorCodesSection
    			// ATTENZIONE: in caso di errore Non si deve riprovare l'invio, trattandosi di errori bloccanti
    			// ------------------------------------------------------------------			
                if ((string)result["status"] == "failed")
                {
                    Console.WriteLine("Sending failed");
                    Console.WriteLine("Code: " + result["code"]);
                    Console.WriteLine("Message: " + result["message"]);
                }
                line = Console.ReadLine();
    
                //// ------------ Controllo del CREDITO RESIDUO -------------
                //credit_result = skebbyGatewayGetCredit("username", "password", "");
    
                //if ((string)credit_result["status"] == "success")
                //{
                //    Console.WriteLine("Current Balance: " + credit_result["credit_left"]);
                //    Console.WriteLine("Remaining SMS Classic: " + credit_result["classic_sms"]);
                //    Console.WriteLine("Remaining SMS Basic: " + credit_result["basic_sms"]);
                //}
    
                //if ((string)credit_result["status"] == "failed")
                //{
                //    Console.WriteLine("Sending request failed");
                //}
                //line = Console.ReadLine();
            }
    
            private static Hashtable skebbyGatewaySendSMS(
                String username, String password,
                String[] recipients, String text,
                String sms_type, String sender_number,
                String sender_string,
                String user_reference,
                String charset)
            {
                String url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php";
                String result = "";
                String[] results, temp;
                String parameters = "";
                String method = "send_sms_classic";
                int i = 0;
                StreamWriter myWriter = null;
                HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                objRequest.ServicePoint.Expect100Continue = false;
                
                Hashtable r = new Hashtable();
    
                switch (sms_type)
                {
                    case SMS_TYPE_CLASSIC:
                        method = "send_sms_classic";
                        break;
                    case SMS_TYPE_CLASSIC_PLUS:
                        method = "send_sms_classic_report";
                        break;
                    case SMS_TYPE_BASIC:
                        method = "send_sms_basic";
                        break;
                    case SMS_TYPE_TEST_CLASSIC:
                        method = "test_send_sms_classic";
                        break;
                    case SMS_TYPE_TEST_CLASSIC_PLUS:
                        method = "test_send_sms_classic_report";
                        break;
                    case SMS_TYPE_TEST_BASIC:
                        method = "test_send_sms_basic";
                        break;
                    default:
                        method = "send_sms_classic";
                        break;
                }
    
                parameters = "method=" + HttpUtility.UrlEncode(method) + "&"
                             + "username=" + HttpUtility.UrlEncode(username) + "&password=" + HttpUtility.UrlEncode(password) + "&"
                             + "text=" + HttpUtility.UrlEncode(text) + "&"
                             + "recipients[]=" + string.Join("&recipients[]=", recipients);
    
                if (sender_number != "" && sender_string != "")
                {
                    r.Add("status", "failed");
                    r.Add("code", "0");
                    r.Add("message", "You can specify only one type of sender, numeric or alphanumeric");
                    return r;
                }
    
                parameters += sender_number != "" ? "&sender_number=" + HttpUtility.UrlEncode(sender_number) : "";
                parameters += sender_string != "" ? "&sender_string=" + HttpUtility.UrlEncode(sender_string) : "";
    
                parameters += user_reference != "" ? "&user_reference=" + HttpUtility.UrlEncode(user_reference) : "";
    
                switch (charset)
                {
                    case "UTF-8":
                        parameters += "&charset=" + HttpUtility.UrlEncode("UTF-8");
                        break;
                    default:
                        break;
                }
    
                objRequest.Method = "POST";
                objRequest.ContentLength = Encoding.UTF8.GetByteCount(parameters);
                objRequest.ContentType = "application/x-www-form-urlencoded";
                HttpWebResponse objResponse;
                try
                {
                    myWriter = new StreamWriter(objRequest.GetRequestStream());
                    myWriter.Write(parameters);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Environment.Exit(1);
                }
                finally
                {
                    myWriter.Close();
                }
                try
                {
                    objResponse = (HttpWebResponse)objRequest.GetResponse();
                }
                catch (WebException e)
                {
                    r.Add("status", "failed");
                    r.Add("code", "0");
                    r.Add("message", "Network error, unable to send the message");
                    return r;
                }
                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                {
                    result = sr.ReadToEnd();
                    // Close and clean up the StreamReader
                    sr.Close();
                }
                results = result.Split('&');
                for (i = 0; i < results.Length; i++)
                {
                    temp = results[i].Split('=');
                    r.Add(temp[0], temp[1]);
                }
                return r;
            }
    
            private static Hashtable skebbyGatewayGetCredit(
               String username, String password,
               String charset)
            {
                String url = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php";
                String method = "get_credit";
                String result = "";
                String[] results, temp;
                String parameters = "";
                int i = 0;
                StreamWriter myWriter = null;
                HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                Hashtable r = new Hashtable();
    
                parameters = "method=" + HttpUtility.UrlEncode(method) + "&"
                           + "username=" + HttpUtility.UrlEncode(username) + "&"
                           + "password=" + HttpUtility.UrlEncode(password);
    
                switch (charset)
                {
                    case "UTF-8":
                        parameters += "&charset=" + HttpUtility.UrlEncode("UTF-8");
                        break;
                    default:
                        break;
                }
    
                objRequest.Method = "POST";
                objRequest.ContentLength = Encoding.UTF8.GetByteCount(parameters);
                objRequest.ContentType = "application/x-www-form-urlencoded";
                HttpWebResponse objResponse;
                try
                {
                    myWriter = new StreamWriter(objRequest.GetRequestStream());
                    myWriter.Write(parameters);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Environment.Exit(1);
                }
                finally
                {
                    myWriter.Close();
                }
                try
                {
                    objResponse = (HttpWebResponse)objRequest.GetResponse();
                }
                catch (WebException e)
                {
                    r.Add("status", "failed");
                    r.Add("code", "0");
                    r.Add("message", "Network error, unable to send the message");
                    return r;
                }
                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                {
                    result = sr.ReadToEnd();
                    // Close and clean up the StreamReader
                    sr.Close();
                }
                results = result.Split('&');
                for (i = 0; i < results.Length; i++)
                {
                    temp = results[i].Split('=');
                    r.Add(temp[0], temp[1]);
                }
                return r;
    
            }
        }
    }					

  • Imports System.Net
    Imports System.IO
    Imports System.Text
    Imports System.Web
    
    Module Module1
    
        Const SMS_TYPE_CLASSIC As String = "classic"
        Const SMS_TYPE_CLASSIC_PLUS As String = "classic_plus"
        Const SMS_TYPE_BASIC As String = "basic"
        Const SMS_TYPE_TEST_CLASSIC As String = "test_classic"
        Const SMS_TYPE_TEST_CLASSIC_PLUS As String = "test_classic_plus"
        Const SMS_TYPE_TEST_BASIC As String = "test_basic"
    
        Private Function skebbyGatewaySendSMS(
                             ByVal username As String, _
                             ByVal password As String, _
                             ByVal recipients() As String, _
                             ByVal text As String, _
                             Optional ByVal sms_type As String = "basic", _
                             Optional ByVal sender_number As String = "", _
                             Optional ByVal sender_string As String = "", _
                             Optional ByVal user_reference As String = "", _
                             Optional ByVal charset As String = "" _
                         ) As Dictionary(Of String, String)
            Dim parameters, method As String
            Dim URL As String
            Dim result As New Dictionary(Of String, String)
            Dim values() As String
            Dim temp
    
            URL = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
    
            method = "send_sms_classic"
    
            Select Case sms_type
                Case SMS_TYPE_CLASSIC
                    method = "send_sms_classic"
                Case SMS_TYPE_CLASSIC_PLUS
                    method = "send_sms_classic_report"
                Case SMS_TYPE_BASIC
                    method = "send_sms_basic"
                Case SMS_TYPE_TEST_CLASSIC
                    method = "test_send_sms_classic"
                Case SMS_TYPE_TEST_CLASSIC_PLUS
                    method = "test_send_sms_classic_report"
                Case SMS_TYPE_TEST_BASIC
                    method = "test_send_sms_basic"
                Case Else
                    method = "send_sms_classic"
            End Select
    
            parameters = "method=" + HttpUtility.UrlEncode(method) + "&" _
                        + "username=" + HttpUtility.UrlEncode(username) + "&" _
                        + "password=" + HttpUtility.UrlEncode(password) + "&" _
                        + "text=" + HttpUtility.UrlEncode(text) + "&" _
                        + "recipients[]=" + String.Join("&recipients[]=", recipients)
    
            If (sender_number <> "") And (sender_string <> "") Then
                result.Add("status", "failed")
                result.Add("code", "0")
                result.Add("message", "You can specify only one type of sender, numeric or alphanumeric")
                Return result
            End If
    
            If sender_number <> "" Then parameters = parameters + "&sender_number=" + HttpUtility.UrlEncode(sender_number)
            If sender_string <> "" Then parameters = parameters + "&sender_string=" + HttpUtility.UrlEncode(sender_string)
            If user_reference <> "" Then parameters = parameters + "&user_reference=" + HttpUtility.UrlEncode(user_reference)
    
            Select Case charset
                Case "UTF-8"
                    parameters = parameters + "&charset=" + HttpUtility.UrlEncode("UTF-8")
                Case Else
            End Select
    
            ' Create POST
            Dim request As WebRequest = WebRequest.Create(URL)
            request.Method = "POST"
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(parameters)
            request.ContentType = "application/x-www-form-urlencoded"
            request.ContentLength = byteArray.Length
            Dim dataStream As Stream = request.GetRequestStream()
            dataStream.Write(byteArray, 0, byteArray.Length)
            dataStream.Close()
    
            Dim response As WebResponse
            Try
                'Trying to get the response.
                response = request.GetResponse()
            Catch ex As System.Net.WebException
                result.Add("status", "failed")
                result.Add("code", "0")
                result.Add("message", "Network error, unable to send the message")
                Return result
            End Try
    
            dataStream = response.GetResponseStream()
            Dim reader As StreamReader = New StreamReader(dataStream)
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Clean up the streams.
            reader.Close()
            dataStream.Close()
            response.Close()
    
            ' Return result to calling function
            If responseFromServer.Length > 0 Then
                values = responseFromServer.Split(New Char() {"&"c})
                For Each value In values
                    temp = value.Split(New Char() {"="c})
                    result.Add(temp(0), temp(1))
                Next
                Return result
            End If
        End Function
    
        Function skebbyGatewayGetCredit(username As String, password As String, Optional charset As String = "") As Dictionary(Of String, String)
            Dim parameters, method As String
            Dim URL As String
            Dim result As New Dictionary(Of String, String)
            Dim values() As String
            Dim temp
    
            URL = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php"
            method = "get_credit"
    
            parameters = "method=" + HttpUtility.UrlEncode(method) + "&" _
                       + "username=" + HttpUtility.UrlEncode(username) + "&" _
                       + "password=" + HttpUtility.UrlEncode(password)
    
            Select Case charset
                Case "UTF-8"
                    parameters = parameters + "&charset=" + HttpUtility.UrlEncode("UTF-8")
                Case Else
            End Select
    
            ' Create POST
            Dim request As WebRequest = WebRequest.Create(URL)
            request.Method = "POST"
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(parameters)
            request.ContentType = "application/x-www-form-urlencoded"
            request.ContentLength = byteArray.Length
            Dim dataStream As Stream = request.GetRequestStream()
            dataStream.Write(byteArray, 0, byteArray.Length)
            dataStream.Close()
    
            Dim response As WebResponse
            Try
                'Trying to get the response.
                response = request.GetResponse()
            Catch ex As System.Net.WebException
                result.Add("status", "failed")
                result.Add("code", "0")
                result.Add("message", "Network error, unable to send the message")
                Return result
            End Try
    
            dataStream = response.GetResponseStream()
            Dim reader As StreamReader = New StreamReader(dataStream)
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Clean up the streams.
            reader.Close()
            dataStream.Close()
            response.Close()
    
            ' Return result to calling function
            If responseFromServer.Length > 0 Then
                values = responseFromServer.Split(New Char() {"&"c})
                For Each value In values
                    temp = value.Split(New Char() {"="c})
                    result.Add(temp(0), temp(1))
                Next
                Return result
            End If
    
        End Function
    
        Sub Main()
    
            Dim result
            Dim credit_result
    
            ' Single dispatch
            Dim recipients(0) As String
            recipients(0) = "393471234567"
    
            ' Multiple dispatch
            ' Dim recipients(1) As String
            ' recipients(0) = "393471234567"
            ' recipients(1) = "393477654321"
    
            ' ------------ SMS Classic dispatch --------------
    
            ' SMS CLASSIC dispatch with custom alphanumeric sender
            result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_CLASSIC, "", "John")
    
            ' SMS CLASSIC dispatch with custom numeric sender
            ' result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_CLASSIC, "393471234567")
    
    
            ' ------------- SMS Basic dispatch ----------------
            ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you? By John", SMS_TYPE_BASIC)
    
    
            ' ------------ SMS Classic Plus dispatch -----------
    
            ' SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
            ' result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS, "", "John")
    
            ' SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
            ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"393471234567")
    
            ' SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender and custom reference string
            ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_CLASSIC_PLUS,"393471234567","","reference")
    
            ' ------------------------------------------------------------------
            '     WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS 
            '     USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
            ' ------------------------------------------------------------------
    
    
            ' ------------- SMS Classic test dispatch ---------
    
            ' SMS CLASSIC test dispatch with custom alphanumeric sender
            ' result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC, "", "John")
    
            ' SMS CLASSIC test dispatch with custom numeric sender
            ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC,"393471234567")
    
    
            ' ------------- Testing invio SMS Classic Plus ---------
    
            ' SMS CLASSIC PLUS test dispatch (with delivery report) with custom alphanumeric sender
            ' result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS, "", "John")
    
            ' SMS CLASSIC PLUS test dispatch (with delivery report) with custom numeric sender
            ' result = skebbyGatewaySendSMS("username","password",recipients,"Hi Mike, how are you?", SMS_TYPE_TEST_CLASSIC_PLUS,"393471234567")
    
    
            ' ------------- SMS Basic test dispatch ---------------
            ' result = skebbyGatewaySendSMS("username", "password", recipients, "Hi Mike, how are you? By John", SMS_TYPE_TEST_BASIC)
    
    
            If result("status") = "success" Then
                Console.WriteLine("Message Sent!")
                Console.WriteLine("Remaining SMSs: " + result("remaining_sms"))
    
                If (result.ContainsKey("id")) Then
                    Console.WriteLine("ID: " + result("id"))
                End If
            End If
    
    		' ------------------------------------------------------------------
    		' Check the complete documentation at http:#www.skebby.com/business/index/send-docs/ 
    		' ------------------------------------------------------------------
    		' For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    		' WARNING: in case of error DON'T retry the sending, since they are blocking errors
    		' ------------------------------------------------------------------					
            If result("status") = "failed" Then
                Console.WriteLine("Sendign Failed")
                Console.WriteLine("Code:" + result("code"))
                Console.WriteLine("Description:" + result("message"))
            End If
            Console.ReadLine()
    
            ' ------------ REMAINING CREDIT Check -------------
            'credit_result = skebbyGatewayGetCredit("username", "password")
    
            'If credit_result("status") = "success" Then
            '    Console.WriteLine("Current Balance: " + credit_result("credit_left"))
            '    Console.WriteLine("Remaining SMS Classic: " + credit_result("classic_sms"))
            '    Console.WriteLine("Remaining SMS Basic: " + credit_result("basic_sms"))
            'End If
            'If credit_result("status") = "failed" Then
            '    Console.WriteLine("Sending request failed")
            'End If
            'Console.ReadLine()
    
        End Sub
    
    End Module					

  • /*
        If you use maven, add the folowing dependency to your pom.xml.
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.1</version>
        </dependency>
    
        Otherwise download Apache HttpComponents from http://hc.apache.org/
        and add the libs to your classpath.
    */
    
    
    
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.HttpVersion;
    import org.apache.http.NameValuePair;
    import org.apache.http.client.entity.UrlEncodedFormEntity;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.message.BasicNameValuePair;
    import org.apache.http.params.BasicHttpParams;
    import org.apache.http.params.HttpConnectionParams;
    import org.apache.http.params.HttpParams;
    import org.apache.http.params.HttpProtocolParamBean;
    import org.apache.http.util.EntityUtils;
    
    public class HttpPostTest {
    
        public static void main(String[] args) throws Exception {
    //      Single dispatch
    //      String [] recipients = new String[]{"391234567890"};
    //      Multiple dispatch
            String [] recipients = new String[]{"391234567890","391234567891"};
    
            String username = "username";
            String password = "password";
    
            // SMS CLASSIC dispatch with custom alphanumeric sender
            String result = skebbyGatewaySendSMS(username, password, recipients, "Hi Mike, how are you?", "send_sms_classic", null, "John");
            
            // SMS Basic dispatch
            // String result = skebbyGatewaySendSMS(username, password, recipients, "Hi Mike, how are you?", "send_sms_basic", null, null);
             
            // SMS CLASSIC dispatch with custom numeric sender
            // String result = skebbyGatewaySendSMS(username, password, recipients, "Hi Mike, how are you?", "send_sms_classic", "393471234567", null);
             
            // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
            // String result = skebbyGatewaySendSMS(username, password, recipients, "Hi Mike, how are you?", "send_sms_classic_report", null, "John");
    
            // SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
            // String result = skebbyGatewaySendSMS(username, password, recipients, "Hi Mike, how are you?", "send_sms_classic_report", "393471234567", null);
    
    		// ------------------------------------------------------------------
    		// Check the complete documentation at http://www.skebby.com/business/index/send-docs/
    		// ------------------------------------------------------------------
    		// For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    		// WARNING: in case of error DON'T retry the sending, since they are blocking errors
    		// ------------------------------------------------------------------	
            System.out.println("result: "+result);
        }
        
        protected static String skebbyGatewaySendSMS(String username, String password, String [] recipients, String text, String smsType, String senderNumber, String senderString) throws IOException{
            return skebbyGatewaySendSMS(username, password, recipients, text, smsType,  senderNumber,  senderString, "UTF-8");
        }
        
        protected static String skebbyGatewaySendSMS(String username, String password, String [] recipients, String text, String smsType, String senderNumber, String senderString, String charset) throws IOException{
            
            if (!charset.equals("UTF-8") && !charset.equals("ISO-8859-1")) {
            
                throw new IllegalArgumentException("Charset not supported.");
            }
            
            String endpoint = "http://gateway.skebby.it/api/send/smseasy/advanced/http.php";
            HttpParams params = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(params, 10*1000);
            DefaultHttpClient httpclient = new DefaultHttpClient(params);
            HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params);
            paramsBean.setVersion(HttpVersion.HTTP_1_1);
            paramsBean.setContentCharset(charset);
            paramsBean.setHttpElementCharset(charset);
            
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            formparams.add(new BasicNameValuePair("method", smsType));
            formparams.add(new BasicNameValuePair("username", username));
            formparams.add(new BasicNameValuePair("password", password));
            if(null != senderNumber)
                formparams.add(new BasicNameValuePair("sender_number", senderNumber));
            if(null != senderString)
                formparams.add(new BasicNameValuePair("sender_string", senderString));
            
            for (String recipient : recipients) {
                formparams.add(new BasicNameValuePair("recipients[]", recipient));
            }
            formparams.add(new BasicNameValuePair("text", text));
            formparams.add(new BasicNameValuePair("charset", charset));
    
        
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, charset);
            HttpPost post = new HttpPost(endpoint);
            post.setEntity(entity);
            
            HttpResponse response = httpclient.execute(post);
            HttpEntity resultEntity = response.getEntity();
            if(null != resultEntity){
                return EntityUtils.toString(resultEntity);
            }
            return null;
        }
    }
    					

  • import urllib
    import urllib2
    
    NET_ERROR = "Network error, unable to send the message"
    SENDER_ERROR = "You can specify only one type of sender, numeric or alphanumeric"
    
    def UrlEncode(recipients):
            resultString = ''
            for number in recipients:
                    resultString = resultString + 'recipients[]=' + urllib.quote_plus(number) + '&'
            return resultString[:-1]
    
    def skebbyGatewaySendSMS(username,password,recipients,text,sms_type='basic',sender_number='',sender_string='',charset='ISO-8859-1',options={ 'User-Agent' : 'Generic Client' }):
            url = 'http://gateway.skebby.it/api/send/smseasy/advanced/http.php'
    
            method = 'send_sms_basic'
    
            if sms_type=='classic' : method = 'send_sms_classic'
            if sms_type=='report' : method = 'send_sms_classic_report'
    
            parameters = {
                    'method' : method,
                    'username' : username,
                    'password' : password,
                    'text' : text
            }
    
            if sender_number != '' and sender_string != '' :
                    result = {}
                    result['status'] = 'failed'
                    result['message'] = SENDER_ERROR
                    return result
    
            if sender_number != '' : parameters['sender_number'] = sender_number
            if sender_string != '' : parameters['sender_string'] = sender_string
    
            if charset != 'ISO-8859-1' : parameters['charset'] = 'UTF-8'
    
            headers = options
            data = urllib.urlencode(parameters) + '&' + UrlEncode(recipients)
    
            req = urllib2.Request(url, data, headers)
            try:
                    response = urllib2.urlopen(req)
            except urllib2.HTTPError as e:
                    result = {}
                    result['status'] = 'failed'
                    result['code'] = e.code
                    result['message'] = NET_ERROR
                    return result
            except urllib2.URLError as e:
                    result = {}
                    result['status'] = 'failed'
                    result['message'] = e.reason
                    return result
    
            resultString = response.read()
    
            results = resultString.split('&')
            result = {}
            for r in results:
                    temp = r.split('=')
                    result[temp[0]] = temp[1]
    
            return result
    
    # Single dispatch
    recipients = ["393471234567"]
    
    # Multiple dispatch
    # recipients = ["393331234567","393331234567"]
    
    # SMS CLASSIC dispatch with custom alphanumeric sender
    result = skebbyGatewaySendSMS('username','password',recipients,'Hi Mike, how are you?','classic','','John')
    
    # SMS CLASSIC dispatch with custom numeric sender
    # result = skebbyGatewaySendSMS('username','password',recipients,'Hi Mike, how are you?','classic','393471234567')
    
    # SMS Basic dispatch
    # result = skebbyGatewaySendSMS('username','password',recipients,'Hi Mike, how are you? By John')
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    # result = skebbyGatewaySendSMS('username','password',recipients,'Hi Mike, how are you?','report','','John')
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    # result = skebbyGatewaySendSMS('username','password',recipients,'Hi Mike, how are you?','report','393471234567')
    if(result['status']=='success'):
    		print "Message sent!\n"
    		print "Remaining SMS: " + result['remaining_sms']
    
    # ------------------------------------------------------------------
    # Controlla la documentazione completa all'indirizzo http:#www.skebby.it/business/index/send-docs/ 
    # ------------------------------------------------------------------
    # Per i possibili errori si veda http:#www.skebby.it/business/index/send-docs/#errorCodesSection
    # ATTENZIONE: in caso di errore Non si deve riprovare l'invio, trattandosi di errori bloccanti
    # ------------------------------------------------------------------
    if(result['status']=='failed'):
    		print "Sending failed\n"
    		try: print "Code: " + str(result['code']) + "\n"
    		except KeyError: pass
    		print "Description: " + str(result['message']) + "\n"					

  • #!/usr/bin/perl
    
    use LWP::UserAgent;
    use URI::Escape;
    use Switch;
    
    use constant NET_ERROR => "Network+error,+unable+to+send+the+message";
    use constant SENDER_ERROR => "You+can+specify+only+one+type+of+sender,+numeric+or+alphanumeric";
    
    sub URLEncode {
    	my $theURL = $_[0];
    	$theURL =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
    	return $theURL;
    }
    
    sub URLDecode {
    	my $theURL = $_[0];
    	$theURL =~ tr/+/ /;
    	$theURL =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;
    	$theURL =~ s/<!-(.|\n)*->//g;
    	return $theURL;
    }
    
    sub skebbyGatewaySendSMS {
    
    	my ($username, $password, $recipients, $text, $sms_type, $sender_number, $sender_string, $charset) = @_;
    
    	$ua = new LWP::UserAgent;
    	$req = new HTTP::Request "POST","http://gateway.skebby.it/api/send/smseasy/advanced/http.php";
    	$req->content_type("application/x-www-form-urlencoded");
    
    	$method = "";
    
    	switch($sms_type) {
    		case "classic" { $method="send_sms_classic"; }
    		case "report" { $method="send_sms_classic_report"; }
    		else { $method="send_sms_basic"; }
    	}
    
    	$query = "method=".$method."&username=".URLEncode($username)."&password=".URLEncode($password).$recipients."&text=".URLEncode($text);
    
    	if($sender_number ne "" && $sender_string ne "") {
    		%results = ();
    		$results{"status"} = "failed";
    		$results{"code"} = "0";
    		$results{"message"} = URLDecode(SENDER_ERROR);
    		return %results;
    	}
    
    	$query = $query.($sender_number ne "" ? "&sender_number=".URLEncode($sender_number) : "");
    	$query = $query.($sender_string ne "" ? "&sender_string=".URLEncode($sender_string) : "");
    
    	switch($charset) {
    		case "UTF-8" { $query = $query."&charset=".URLEncode("UTF-8"); }
    		else {}
    	}
    
    	$req->content($query);
    
    	$res = $ua->request($req);
    
    	if ($res->is_error) {
    		%results = ();
    		$results{"status"} = "failed";
    		$results{"code"} = "0";
    		$results{"message"} = URLDecode(NET_ERROR);
    		return %results;
    	}
    
    	%results = ();
    	@result = split("&", $res->content);
    	foreach (@result) {
    		@temp = split("=",$_);
    		$results{$temp[0]} = $temp[1];
    	}
    
    	return %results;
    }
    
    # Single dispatch
    @recipients = ("393471234567");
    
    # Multiple dispatch
    # @recipients = ("393471234567","393337654321");
    
    $recipients = "&recipients[]=".join("&recipients[]=", @recipients);
    
    # SMS CLASSIC dispatch with custom alphanumeric sender
    %results = skebbyGatewaySendSMS("username","password",$recipients,"Hi Mike, how are you?","classic","","John","");
    
    #  SMS BASIC dispatch
    # %results = skebbyGatewaySendSMS("username","password",$recipients,"Hi Mike, how are you? By John","basic","","","");
    
    # SMS CLASSIC dispatch with custom numeric sender
    # %results = skebbyGatewaySendSMS("username","password",$recipients,"Hi Mike, how are you?","classic","393471234567","","");
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    # %results = skebbyGatewaySendSMS("username","password",$recipients,"Hi Mike, how are you?","report","","John","");
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    # %results = skebbyGatewaySendSMS("username","password",$recipients,"Hi Mike, how are you?","report","393471234567","","");
    
    if ($results{"status"} eq "success") {
    	print "Message Sent!\n";
    	print "Remaining SMS: ".$results{"remaining_sms"};
    }
    
    # ------------------------------------------------------------------
    # Check the complete documentation at http://www.skebby.com/business/index/send-docs/
    # ------------------------------------------------------------------
    # For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    # WARNING: in case of error DON'T retry the sending, since they are blocking errors
    # ------------------------------------------------------------------
    if ($results{"status"} eq "failed") {
    	print "Sending Failed\n";
    	print "Code: ".$results{'code'}."\n";
    	print "Description: ".URLDecode($results{'message'})."\n";
    }					

  • # ------------ SMS Classic dispatch --------------
    
    # ------------------------------------------------------------------
    # Check the complete documentation at http://www.skebby.com/business/index/send-docs/
    # ------------------------------------------------------------------
    # For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    # WARNING: in case of error DON'T retry the sending, since they are blocking errors
    # ------------------------------------------------------------------
    
    # SMS CLASSIC dispatch with custom alphanumeric sender (single dispatch)
    curl --data "method=send_sms_classic&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_string=John" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # SMS CLASSIC dispatch with custom numeric sender (multiple dispatch)
    curl --data "method=send_sms_classic&username=username&password=password&recipients[]=393471234567&recipients[]=393477654321&text=Hi+Mike%2C+how+are+you%3F&sender_string=John" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # SMS CLASSIC dispatch with custom numeric sender
    curl --data "method=send_sms_classic&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_number=393471234567" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # ------------- SMS Basic dispatch ----------------
    curl --data "method=send_sms_basic&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # ------------ SMS Classic Plus dispatch -----------
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    curl --data "method=send_sms_classic_report&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_string=John" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    curl --data "method=send_sms_classic_report&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_number=393471234567" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender and custom reference string
    curl --data "method=send_sms_classic_report&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_number=393471234567&user_reference=riferimento" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # ------------------------------------------------------------------
    #    WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS 
    #    USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
    # ------------------------------------------------------------------
    
    # ------------- SMS Classic test dispatch ---------
    # SMS CLASSIC test dispatch with custom alphanumeric sender
    curl --data "method=test_send_sms_classic&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_string=John" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # SMS CLASSIC test dispatch with custom numeric sender
    curl --data "method=test_send_sms_classic&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_number=393471234567" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # ------------ SMS Classic Plus test dispatch -----------
    
    # SMS CLASSIC PLUS test dispatch (with delivery report) with custom alphanumeric sender
    curl --data "method=test_send_sms_classic_report&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_string=John" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # SMS CLASSIC PLUS test dispatch (with delivery report) with custom numeric sender
    curl --data "method=test_send_sms_classic_report&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you%3F&sender_number=393471234567" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # ------------- SMS Basic test dispatch ----------------
    curl --data "method=test_send_sms_basic&username=username&password=password&recipients[]=393471234567&text=Hi+Mike%2C+how+are+you" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    
    # ------------ REMAINING CREDIT Check -------------
    curl --data "method=get_credit&username=username&password=password" http://gateway.skebby.it/api/send/smseasy/advanced/http.php
    					

  • var qs = require('querystring');
    var https = require('https');
    
    var send_sms_skebby = function(input,cb,cb_err){
        var text = input.text;
        var sender_number = input.sender_number || "";
        var sender_string = input.sender_string || "";
    	var method = input.method;
        var lrecipients = input.recipients || [];
        var username = input.username;
        var password = input.password;
        
    	if(!method){
    		cb_err("No Method!");
    		return;
        }
    
    	switch(method) {
            case 'classic':
                method='send_sms_classic';
                break;
            case 'report':
                method='send_sms_classic_report';
                break;
            case 'basic':
            default:
                method='send_sms_basic';
        }
        
    	var test = input.test || false;
        
        // Check params
        if(lrecipients.length == 0){
    		cb_err("No recipient!");
    		return;
        }
    
        if(!sender_string && !sender_number){
    		cb_err("No sender!");
    		return;
        }
    
        if(!text){
    		cb_err("No text!");
    		return;
        }    
        
        var params = {
    		method : method,
    		username : username,
    		password : password,
    		"recipients[]" : lrecipients,
    		text : text,
    		charset : "UTF-8",
        };
    
        if(sender_number){
    		params.sender_number = sender_number;
        }
        else if(sender_string){
    		params.sender_string = sender_string;
        }
    
        if(test){
    		params.method = "test_"+params.method;
        }
        
        var res_done = false;
        var data = qs.stringify(params);
    
        var client = https.request({
        	port : 443,
        	path : "/api/send/smseasy/advanced/http.php",
        	host: "gateway.skebby.it",
        	method : "POST", 
        	headers: { 
        	    "Content-Type" : "application/x-www-form-urlencoded",
        	    "Content-Length": data.length,
        	    "Content-Encoding" : "utf8",
        	}
        },function(res){
        	var res_data = "";
        	res.on('data', function(data) {
        	    res_data+=data;
        	});
        	res.on("end",function(){
        	    if (!res_done){
    		var res_parsed = qs.parse(res_data);
    		if(res_parsed.status == "success"){
    		    cb({data:res_parsed});
    		}
    		else{
    			// ------------------------------------------------------------------
    			// Check the complete documentation at http://www.skebby.com/business/index/send-docs/
    			// ------------------------------------------------------------------
    			// For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    			// WARNING: in case of error DON'T retry the sending, since they are blocking errors
    			// ------------------------------------------------------------------		
    		    cb_err(res_parsed);
    		}
        		res_done = true;
        	    }
        	});
        });	
    
        client.end(data);
        client.on('error', function(e) {
        	if (!res_done){
        	    cb_err(e);
        	    res_done = true;
        	}
        });
    };
    
    // SMS CLASSIC dispatch
    send_sms_skebby( {
    	method : "classic",
    	username : "username",
    	password : "password", 
        recipients : ["393396803445"],
        //recipients : ["393396803445","393395352490"],
        text : "Hi Mike, how are you?2",
    },function(res){
        console.log(res.data);
    },function(err){
        console.log(err);
    });
    
    /*
    // SMS Basic dispatch
    send_sms_skebby( {
    	method : "basic",
    	username : "username",
    	password : "password", 
        recipients : ["393396803445"],
        //recipients : ["393396803445","393395352490"],
        text : "Hi Mike, how are you? By John",
    },function(res){
        console.log(res.data);
    },function(err){
        console.log(err);
    });
    
    // SMS CLASSIC dispatch with custom numeric sender
    send_sms_skebby( {
    	method : "classic",
    	username : "username",
    	password : "password",
        sender_number : "393471234567",
        recipients : ["393396803445"],
        //recipients : ["393396803445","393395352490"],
        text : "Hi Mike, how are you?",
    },function(res){
        console.log(res.data);
    },function(err){
        console.log(err);
    });
    
    // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    send_sms_skebby( {
    	method : "report",
    	username : "username",
    	password : "password",
        sender_string : "John",   
        recipients : ["393396803445"],
        //recipients : ["393396803445","393395352490"],
        text : "Hi Mike, how are you?",
    },function(res){
        console.log(res.data);
    },function(err){
        console.log(err);
    });
    
    // SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    send_sms_skebby( {
    	method : "report",
    	username : "username",
    	password : "password",
        sender_number : "393471234567",  
        recipients : ["393396803445"],
        //recipients : ["393396803445","393395352490"],
        text : "Hi Mike, how are you?",
    },function(res){
        console.log(res.data);
    },function(err){
        console.log(err);
    });
    */					

  • require 'net/http'
    require 'uri'
    require 'cgi'
    
    class SkebbyGatewaySendSMS
      
    	def initialize(username = '', password = '')
    		@url = 'http://gateway.skebby.it/api/send/smseasy/advanced/http.php'
    
    		@parameters = {
    			'username'		=> username,
    			'password'		=> password,
    		}
    	end
    
    	def sendSMS(method, text, recipients, options = {})
    	  unless recipients.kind_of?(Array)
    	    raise("recipients must be an array")
    	  end
    	
    	  @parameters['method'] = method
    	  @parameters['text'] = text
    	  
    	  @parameters["recipients[]"] = recipients
      
        unless options[:senderNumber].nil?
         @parameters['sender_number'] = options[:senderNumber]
        end
    
        unless options[:senderString].nil?
         @parameters['sender_string'] = options[:senderString]
        end
    
        unless options[:charset].nil?
         @parameters['charset'] = options[:charset]
        end
            
        @parameters.each {|key, value| puts "#{key} is #{value}" }    
            
    		@response = Net::HTTP.post_form(URI(@url), @parameters)
    		if @response.message == "OK"
    			true
    		else
    			false
    		end
    		
    	end
    	
    	def getCredit()
    	  
        @parameters['method']	= 'get_credit'
        
    		@response = Net::HTTP.post_form(URI(@url), @parameters)
    		if @response.message == "OK"
    			true
    		else
    			false
    		end
    	end
    	
    	def getResponse
    		result = {}
    		@response.body.split('&').each do |res|
    			if res != ''
    				temp = res.split('=')
    				if temp.size > 1
    					result[temp[0]] = temp[1]
    				end
    			end
    		end
    		return result
    	end
    
    	def printResponse
    		result = self.getResponse
    		if result.has_key?('status') and result['status'] == 'success'
    			puts "Success, response contains:"
    			result.each do |key,value|
    				puts "\t#{key} => #{CGI::unescape(value)}"
    			end
    			true
    		else
    			# ------------------------------------------------------------------
    			# Check the complete documentation at http:#www.skebby.com/business/index/send-docs/
    			# ------------------------------------------------------------------
    			# Per i possibili errori si veda http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    			# ATTENZIONE: in caso di errore Non si deve riprovare l'invio, trattandosi di errori bloccanti
    			# ------------------------------------------------------------------		
    			puts "Error, trace is:"
    			result.each do |key,value|
    				puts "\t#{key} => #{CGI::unescape(value)}"
    			end
    			false
    		end
    	end
    
    end
    
    gw = SkebbyGatewaySendSMS.new('username', 'password')
    
    #Single dispatch
    recipients = ["393471234567"]
    
    #Multiple dispatch
    #recipients = ["393471234567","393497654321"]
    
    #SMS CLASSIC dispatch with custom alphanumeric sender
    result = gw.sendSMS('send_sms_classic', 'Hi Mike, how are you', recipients, { :senderString => 'Jhon' } )
    
    #SMS CLASSIC dispatch with custom numeric sender
    #result = gw.sendSMS('send_sms_classic', 'Hi Mike, how are you', recipients, { :senderNumber => '393471234567' } )
    
    #SMS Basic dispatch
    #result = gw.sendSMS('send_sms_basic', 'Hi Mike, how are you? By John', recipients )
    
    #SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
    #result = gw.sendSMS('send_sms_classic_report', 'Hi Mike, how are you', recipients, { :senderString => 'Jhon' } )
    
    #SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    #result = gw.sendSMS('send_sms_classic_report', 'Hi Mike, how are you', recipients, { :senderNumber => '393471234567' } )
    
    #Remaining Credit Check
    #result = gw.getCredit()
    
    if result
    	gw.printResponse
    else
      puts "Error in the HTTP request"
    end					

  • /*
    SKEBBYGATEWAYAPI C++ EXAMPLE
    TOTI PIERANDREA
    SKEBBY
    MOBILE SOLUTIONS S.R.L.
    
    WARNING: THIS EXAMPLE USES CROSSPLATFORM LIBRARY "LIBCURL": YOU CAN DOWNLOAD IT AT http://curl.haxx.se/
    */
    
    #include <iostream>
    #include <string>
    #include <vector>
    #include "curl\curl.h"
    
    using namespace std;
    
    #define SMS_TYPE_CLASSIC 0
    #define SMS_TYPE_CLASSIC_PLUS  1
    #define SMS_TYPE_BASIC   2
    #define SMS_TYPE_TEST_CLASSIC  3
    #define SMS_TYPE_TEST_CLASSIC_PLUS  4
    #define SMS_TYPE_TEST_BASIC  5
    
    #define utf8(str)  ConvertToUTF8(L##str)
    
    #ifdef _WIN32
    
    const string ConvertToUTF8(const wchar_t * pStr)
    {
    	static char szBuf[1024];
    	WideCharToMultiByte(CP_UTF8, 0, pStr, -1, szBuf, sizeof(szBuf), NULL, NULL);
    	string ret(szBuf);
    	return ret;
    }
    
    #else
    
    const string ConvertToUTF8(const wstring& src)
    {
    	string ret = "";
    	for (size_t i = 0; i < src.size(); i++){
    		wchar_t w = src[i];
    		if (w <= 0x7f)
    			ret.push_back((char)w);
    		else if (w <= 0x7ff)
    		{
    			ret.push_back(0xc0 | ((w >> 6)& 0x1f));
    			ret.push_back(0x80| (w & 0x3f));
    		}
    		else if (w <= 0xffff)
    		{
    			ret.push_back(0xe0 | ((w >> 12)& 0x0f));
    			ret.push_back(0x80| ((w >> 6) & 0x3f));
    			ret.push_back(0x80| (w & 0x3f));
    		}
    		else if (w <= 0x10ffff)
    		{
    			ret.push_back(0xf0 | ((w >> 18)& 0x07));
    			ret.push_back(0x80| ((w >> 12) & 0x3f));
    			ret.push_back(0x80| ((w >> 6) & 0x3f));
    			ret.push_back(0x80| (w & 0x3f));
    		}
    		else
    			ret.push_back('?');
    	}
    	return ret;
    }
    
    #endif
    
    size_t write_to_string(void *ptr, size_t size, size_t count, void *stream)
    {
    	((string*)stream)->append((char*)ptr, 0, size*count);
    	return size*count;
    }
    
    static string skebbyGatewaySendSMS(const string &username, const string &password,
    	vector<string> &recipients,const string &text,const string &sms_type,
    	const string &sender_number, const string &sender_string, const string &user_reference)
    {
    	CURL *curl;
    	CURLcode res;
    
    	struct curl_httppost *formpost=NULL;
    	struct curl_httppost *lastptr=NULL;
    	struct curl_slist *headerlist=NULL;
    	static const char buf[] = "Expect:";
    
    	curl_global_init(CURL_GLOBAL_ALL);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "method",
    		CURLFORM_COPYCONTENTS, &sms_type[0],
    		CURLFORM_END);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "username",
    		CURLFORM_COPYCONTENTS, &username[0],
    		CURLFORM_END);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "password",
    		CURLFORM_COPYCONTENTS, &password[0],
    		CURLFORM_END);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "charset",
    		CURLFORM_COPYCONTENTS, "UTF-8",
    		CURLFORM_END);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "text",
    		CURLFORM_COPYCONTENTS, &text[0],
    		CURLFORM_END);
    
    	for (vector<string>::iterator i = recipients.begin();i != recipients.end();++i)
    	{
    		curl_formadd(&formpost,
    			&lastptr,
    			CURLFORM_COPYNAME, "recipients[]",
    			CURLFORM_COPYCONTENTS, &(*i)[0],
    			CURLFORM_END);
    	}
    
    	if(sender_number.length() > 0 )
    	{
    		curl_formadd(&formpost,
    			&lastptr,
    			CURLFORM_COPYNAME, "sender_number",
    			CURLFORM_COPYCONTENTS, &sender_number[0],
    			CURLFORM_END);
    	}
    
    	if(sender_string.length() > 0 )
    	{
    		curl_formadd(&formpost,
    			&lastptr,
    			CURLFORM_COPYNAME, "sender_string",
    			CURLFORM_COPYCONTENTS, &sender_string[0],
    			CURLFORM_END);
    	}
    
    	if(user_reference.length() > 0 )
    	{
    		curl_formadd(&formpost,
    			&lastptr,
    			CURLFORM_COPYNAME, "user_reference",
    			CURLFORM_COPYCONTENTS, &user_reference[0],
    			CURLFORM_END);
    	}
    
    
    	headerlist = curl_slist_append(headerlist, buf);
    	curl = curl_easy_init();
    
    	if(curl)
    	{
    
    		string response;
    		curl_easy_setopt(curl, CURLOPT_URL, "http://gateway.skebby.it/api/send/smseasy/advanced/http.php");
    		curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
    		curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
    		curl_easy_setopt(curl, CURLOPT_TIMEOUT, 100);
    		curl_easy_setopt(curl, CURLOPT_ENCODING, "UTF-8" );
    		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_to_string);
    		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
    		res = curl_easy_perform(curl);
    
    		// always cleanup
    		curl_easy_cleanup(curl);
    		curl_formfree(formpost);
    		curl_slist_free_all (headerlist);
    
    		if(res == CURLE_OK )
    			return response;
    	}
    	return "Error Occured";
    }
    
    
    static string skebbyGatewayGetCredit(const string &username,const string &password)
    {
    	CURL *curl;
    	CURLcode res;
    
    	struct curl_httppost *formpost=NULL;
    	struct curl_httppost *lastptr=NULL;
    
    	curl_global_init(CURL_GLOBAL_ALL);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "method",
    		CURLFORM_COPYCONTENTS, "get_credit",
    		CURLFORM_END);
    
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "username",
    		CURLFORM_COPYCONTENTS, &username[0],
    		CURLFORM_END);
    
    	curl_formadd(&formpost,
    		&lastptr,
    		CURLFORM_COPYNAME, "password",
    		CURLFORM_COPYCONTENTS, &password[0],
    		CURLFORM_END);
    
    	curl = curl_easy_init();
    
    	if(curl)
    	{
    		string response;
    		curl_easy_setopt(curl, CURLOPT_URL, "http://gateway.skebby.it/api/send/smseasy/advanced/http.php");
    		curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
    		curl_easy_setopt(curl, CURLOPT_TIMEOUT, 100);
    		curl_easy_setopt(curl, CURLOPT_ENCODING, "UTF-8" );
    		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_to_string);
    		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
    		res = curl_easy_perform(curl);
    		curl_easy_cleanup(curl);
    		curl_formfree(formpost);
    
    		if(res == CURLE_OK )
    			return response;
    	}
    
    	return "Error Occured";
    }
    
    int main()
    {
    
    	string username = utf8("username");
    	string password = utf8("password");
    	vector<string> recipients;
    
    	// Invio singolo
    	recipients.push_back("393471234567");	
    	
    	// Per invio multiplo
    	// recipients.push_back("393471234567");
    	// recipients.push_back("393477654321");
    
    	string smstype[6] = {"send_sms_classic","send_sms_classic_report","send_sms_basic","test_send_sms_classic","test_send_sms_classic_report","test_send_sms_basic"} ;
    	string message = utf8("Hi Mike, how are you?");
    	string result;
    
    	// ------------------------------------------------------------------
    	// Check the complete documentation at http://www.skebby.com/business/index/send-docs/
    	// ------------------------------------------------------------------
    	// For eventual errors see http:#www.skebby.com/business/index/send-docs/#errorCodesSection
    	// WARNING: in case of error DON'T retry the sending, since they are blocking errors
    	// ------------------------------------------------------------------
    	
    	// ------------ SMS Classic dispatch --------------
    
    	// SMS CLASSIC dispatch with custom alphanumeric sender
    	 result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_CLASSIC], "393471234567", "John", "");
    
    	// SMS CLASSIC dispatch with custom numeric sender
        // result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_CLASSIC], "393471234567", "", "");
    
    	// ------------- SMS Basic dispatch ----------------
        // result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_BASIC], "", "", "");
    
    	// ------------ SMS Classic Plus dispatch -----------
    
        // SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender
        // result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_CLASSIC_PLUS], "", "John", "");
    
        // SMS CLASSIC PLUS dispatch (with delivery report) with custom numeric sender
    	// result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_CLASSIC_PLUS], "393471234567", "", "");
    
    	// SMS CLASSIC PLUS dispatch (with delivery report) with custom alphanumeric sender and custom reference string
    	// result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_CLASSIC_PLUS], "393471234567", "", "riferimento");
    
    
        //  ------------------------------------------------------------------
    	//     WARNING! THE SMS_TYPE_TEST* SMS TYPES DOESN'T DISPATCH ANY SMS 
    	//     USE THEM ONLY TO CHECK IF YOU CAN REACH THE SKEBBY SERVER 
    	//  ------------------------------------------------------------------
    
        // ------------- SMS Classic test dispatch ---------
    
        // SMS CLASSIC test dispatch with custom alphanumeric sender
    	// result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_TEST_CLASSIC], "", "John", "");
    
        // SMS CLASSIC test dispatch with custom numeric sender
    	// result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_TEST_CLASSIC], "393471234567", "", "");
    
    
        // ------------ SMS Classic Plus test dispatch -----------
    
        // SMS CLASSIC PLUS test dispatch (with delivery report) with custom alphanumeric sender
        // result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_TEST_CLASSIC_PLUS], "", "John", "");
    
        // SMS CLASSIC PLUS test dispatch (with delivery report) with custom numeric sender
        // result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_TEST_CLASSIC_PLUS], "393471234567", "", "");
    
    	
        // ------------- SMS Basic test dispatch ----------------
        // result = skebbyGatewaySendSMS(username, password, recipients, message, smstype[SMS_TYPE_TEST_BASIC], "", "", "");
    
    	// ------------ REMAINING CREDIT Check -------------
    	// result = skebbyGatewayGetCredit(username,password);
    
    	cout << result << endl;
    	return 0;
    }					

  • // EXAMPLE PROJECT FOR RAD STUDIO IS AVAILABLE HERE:
    // http://static.skebby.it/s/apps/gateway/send/skebby-gw-radstudio-delphi-example.zip
    {==============================================================================|
    | Project : Skebby Gateway SMS                                                 |
    |==============================================================================|
    | Content: Delphi Gateway Example                                              |
    |==============================================================================|
    | The example is tested on Embarcadero RAD Studio XE5						   |
    | Is recommended the creation of a TFormEsempio Form with a SkebbySendSMS 	   |
    | button and the integration of Delphi Synapse libraries					   |
    | URL: http://www.ararat.cz/synapse/ to get the latest SVN version		   	   | 	
    |==============================================================================}
    
    unit Skebby;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, blcksock, synacode, httpsend;
    
    type
      TFormEsempio = class(TForm)
        SkebbySendSMS: TButton;
        procedure SkebbySendSMSClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      FormEsempio: TFormEsempio;
    
    
    type TSkebbySMSType = (smsTestClassic, smsBasic, smsClassic, smsClassicPlus);// 0=Test Classic, 1=Basic, 2=Classic, 3=Classic Plus
    
    type TSkebbyResponse = record
      status: string;
      code: string;
      msg: string;
      remainingSMS: string;
      credit: Double;
      sms_basic_left: integer;
      sms_classic_left: integer;
    end;
    
    type TSkebbyGateway = class
      private
        FURLGateway: string;
        FUsername: string;
        FPassword: string;
        FTipoSMS: integer;
        FNumeroMittente: string;
        FNomeMittente: string;
        FRecipients: TStringList;
        FMessaggio: string;
    
        FParams: string;
    
        procedure PrepareSMSParams(smsType: TSkebbySMSType);
        procedure PrepareCreditParams;
    
        function ParseSMSResponse(resp: string): TSkebbyResponse;
        function ParseCreditResponse(resp: string): TSkebbyResponse;
      public
    
        constructor Create;
        destructor Destroy; override;
    
        procedure AddDestinatario(numero: string);
        procedure SetSMSText(testo: string);
    
        function TestServizio: TSkebbyResponse;
        function GetCredito: TSkebbyResponse;
        function SendSMS(tipo: TSkebbySMSType): TSkebbyResponse;
    end;
    
    const
      TEST_SMS_CLASSIC = 'test_send_sms_classic';
      TEST_SMS_BASIC = 'test_send_sms_basic';
    
      SMS_BASIC = 'send_sms_basic';
      SMS_CLASSIC = 'send_sms_classic';
      SMS_CLASSIC_PLUS = 'send_sms_classic_report';
    
      SMS_SUCCESS = 'success';
      SMS_FAILED = 'failed';
    
    implementation
    {$R *.dfm}
    
    
    { TSkebbyGateway }
    
    procedure TSkebbyGateway.AddDestinatario(numero: string);
    begin
      FRecipients.Add(numero);
      inherited;
    end;
    
    constructor TSkebbyGateway.Create;
    begin
      FRecipients := TStringList.Create;
    
    // CONFIGURATION VARIABLES
    // INSERT LOGIN CREDENTIALS AND SMS CONFIG HERE
      FMessaggio := '';
      FURLGateway := 'http://gateway.skebby.it/api/send/smseasy/advanced/http.php';
      FUsername := 'username';
      FPassword := 'password';
      FTipoSMS := 2;
      FNumeroMittente := '';
      FNomeMittente := 'John';
    end;
    
    destructor TSkebbyGateway.Destroy;
    begin
      FRecipients.Free;
    end;
    
    
    function TSkebbyGateway.GetCredito: TSkebbyResponse;
    var
      chk: Boolean;
      stm: TStringStream;
    begin
      stm := TStringStream.Create('');
    
      PrepareCreditParams;
    
      try
        chk := HttpPostURL(FURLGateway, FParams, stm);
        if chk then
        begin
          Result := ParseCreditResponse(stm.DataString);
        end
        else
        begin
          Result.status := SMS_FAILED;
          Result.msg := 'Errore durante il collegamento con il server SMS!';
        end;
      finally
        stm.Free;
      end;
    end;
    
    function TSkebbyGateway.ParseSMSResponse(resp: string): TSkebbyResponse;
    var
      list: TStringList;
    begin
      list := TStringList.Create;
      try
        list.Text := StringReplace(resp, '&', #13#10, [rfReplaceAll]);
        Result.status := list.Values['status'];
        if Result.status = SMS_SUCCESS then
        begin
          Result.msg := 'Message sent!';
          Result.remainingSMS := list.Values['remaining_sms'];
        end;
    
        if Result.status = SMS_FAILED then
        begin
          Result.code := list.Values['code'];
          Result.msg := list.Values['message'];
        end;
      finally
        list.Free;
      end;
    end;
    
    function TSkebbyGateway.ParseCreditResponse(resp: string): TSkebbyResponse;
    var
      list: TStringList;
    begin
      list := TStringList.Create;
      try
        list.Text := StringReplace(resp, '&', #13#10, [rfReplaceAll]);
        Result.status := list.Values['status'];
        if Result.status = SMS_SUCCESS then
        begin
          Result.credit := StrToFloatDef(list.Values['credit_left'], 0.0);
          Result.sms_basic_left := StrToIntDef(list.Values['basic_sms'], 0);
          Result.sms_classic_left := StrToIntDef(list.Values['classic_sms'], 0);
        end;
    
        if Result.status = SMS_FAILED then
        begin
          Result.code := '';
          Result.msg := 'Sending request failed!';
        end;
      finally
        list.Free;
      end;
    end;
    
    procedure TSkebbyGateway.PrepareCreditParams;
    var
      urlParams: string;
    begin
      FParams := '';
    
      urlParams := '';
      urlParams := urlParams + 'method=get_credit&';
      urlParams := urlParams + 'username=' + EncodeURLElement(FUsername) + '&';
      urlParams := urlParams + 'password=' + EncodeURLElement(FPassword) + '&';
    
      FParams := urlParams;
    end;
    
    procedure TSkebbyGateway.PrepareSMSParams(smsType: TSkebbySMSType);
    var
      k: Integer;
      urlParams: string;
    begin
      FParams := '';
    
      urlParams := '';
    
      case smsType of
        smsTestClassic:
          urlParams := urlParams + 'method=' + EncodeURLElement(TEST_SMS_CLASSIC) + '&';
        smsBasic:
          urlParams := urlParams + 'method=' + EncodeURLElement(SMS_BASIC) + '&';
        smsClassic:
          urlParams := urlParams + 'method=' + EncodeURLElement(SMS_CLASSIC) + '&';
        smsClassicPlus:
          urlParams := urlParams + 'method=' + EncodeURLElement(SMS_CLASSIC_PLUS) + '&';
      else // default usa il metodo TEST
        urlParams := urlParams + 'method=' + EncodeURLElement(TEST_SMS_CLASSIC) + '&';
      end;
    
      urlParams := urlParams + 'username=' + EncodeURLElement(FUsername) + '&';
      urlParams := urlParams + 'password=' + EncodeURLElement(FPassword) + '&';
      urlParams := urlParams + 'text=' + EncodeURLElement(FMessaggio) + '&';
    
      for k:=0 to FRecipients.Count - 1 do
      begin
        urlParams := urlParams + 'recipients[]=' + EncodeURLElement(FRecipients[k]) + '&';
      end;
    
      if FNumeroMittente <> '' then
        urlParams := urlParams + 'sender_number=' + EncodeURLElement(FNumeroMittente) + '&';
      if FNomeMittente <> '' then
        urlParams := urlParams + 'sender_string=' + EncodeURLElement(FNomeMittente) + '&';
    
    
      FParams := urlParams;
    end;
    
    procedure TSkebbyGateway.SetSMSText(testo: string);
    begin
      FMessaggio := testo;
    end;
    
    function TSkebbyGateway.TestServizio: TSkebbyResponse;
    begin
      Result := SendSMS(smsTestClassic);
    end;
    
    function TSkebbyGateway.SendSMS(tipo: TSkebbySMSType): TSkebbyResponse;
    var
      chk: Boolean;
      stm: TStringStream;
    begin
      PrepareSMSParams(tipo);
    
      stm := TStringStream.Create('');
      try
        chk := HttpPostURL(FURLGateway, FParams, stm);
        if chk then
        begin
          Result := ParseSMSResponse(stm.DataString);
        end
        else
        begin
          Result.status := SMS_FAILED;
          Result.msg := 'Network with the SMS Server connection!';
        end;
      finally
        stm.Free;
      end;
    end;
    
    
    
    procedure TFormEsempio.SkebbySendSMSClick(Sender: TObject);
    var
      sms: TSkebbyGateway;
      resp: TSkebbyResponse;
    begin
      sms := TSkebbyGateway.Create;
      try
      	// Destinatari:
        sms.AddDestinatario('393491234567');
        // sms.AddDestinatario('393331234567');
        // Testo:
        sms.SetSMSText('Hi Mike, how are you?');
        // Tipo Messaggio:
        // smsBasic   		= send_sms_basic
        // smsClassic 		= send_sms_classic
        // smsClassicPlus	= send_sms_report
        // testSmsClassic	= test_send_sms_classic
        resp := sms.SendSMS(smsClassic);
        if resp.status = SMS_SUCCESS then
        begin
          // resp.remainingSMS contains the Remaining SMS count
          ShowMessage('Message Sent');
        end
        else
        begin
          // resp.msg contains the error code
          ShowMessage('Sending Failed');
        end;
      finally
        sms.free;
      end;
    end;
    
    end.					

Receive SMS examples

Below you'll find a selection of examples that you can copy and modify as needed. If you require help, contact us
Copy to clipboard


  • <?php
    	$sender = $_POST['sender'];
    	$receiver = $_POST['receiver'];
    	$text = $_POST['text'];
    	$encoding = $_POST['encoding'];
    	$date = $_POST['date'];
    	$time = $_POST['time'];
    	$timestamp = $_POST['timestamp'];
    	$smsType = $_POST['smsType'];
    	
    	// data MUST BE SAVED in a file or in a database for memorization to be stored and managed
    
    ?>
    /*
     * sender	SMS Sender's Numnber in international format without "+" or "00", Example: 393334455666
     * receiver	The number where the SMS has arrived in international format without "+" or "00", Example: 393334455666
     * text		SMS text
     * encoding	The character encoding scheme used for the text (ISO-8859-1)
     * date		SMS delivery date 
     * time		SMS delivery time
     * timestamp	SMS delivery timestamp. For programmer's convenience, we pass 3 different date/time formats
     * smsType	type of the Received SMS (standard o skebby)
     */					

  • <%
    	sender = Request.Form("sender")
    	receiver = Request.Form("receiver")
    	text = Request.Form("text")
    	encoding = Request.Form("encoding")
    	date = Request.Form("date")
    	time = Request.Form("time")
    	timestamp = Request.Form("timestamp")
    	smsType = Request.Form("smsType")
    	
    	' data MUST BE SAVED in a file or in a database for memorization to be stored and managed
    
    %>
    '
    ' sender	SMS Sender's Numnber in international format without "+" or "00", Example: 393334455666
    ' receiver	The number where the SMS has arrived in international format without "+" or "00", Example: 393334455666
    ' text		SMS text
    ' encoding	The character encoding scheme used for the text (ISO-8859-1)
    ' date		SMS delivery date 
    ' time		SMS delivery time
    ' timestamp	SMS delivery timestamp. For programmer's convenience, we pass 3 different date/time formats
    ' smsType	type of the Received SMS (standard o skebby)
    '					

You might find it useful to read our full documentation to understand how to use these APIs