}}
    Show / Hide Table of Contents

    A Basic Test Request

    So far we have covered basic requirements in setting up for messaging with our SDKs. In this section, we will consider a minimal program to test integration setup. After a successful test, the subsequent sections will delve deeper in messaging.

    In this test program, we will only look at a sample code to return account balance. It will cover some of the basic request procedures discussed earlier.

    • C#
    • VB/VBA
    • VB.NET
    • Java
    • PHP
    • Python
    using System;
    	
    using Zenoph.Notify.Enums;
    using Zenoph.Notify.Request;
    using Zenoph.Notify.Response;
    	
    public class Test {
        public static void Main(){
            try {			
                // create request object
                CreditBalanceRequest request = new CreditBalanceRequest();
    			
                // set the request host domain
                request.setHost("api.smsonlinegh.com");
    			
                // By default requests will be sent using SSL/TLS with https connection.
                // If you encounter SSL/TLS warning or error, your machine may be using unsupported
                // SSL/TLS version. In that case uncomment the following line to set it to false
                // request.useSecureConnection(false);
    			
                // set authentication parameters
                request.setAuthModel(AuthModel.API_KEY);
                request.setAuthApiKey("d5c683a1b4c3d2f278be3d4c03c23191b2f133378b12b6e197c1ad5d9b34c128");
    			
                // get the balance
                CreditBalanceResponse response = request.submit() as CreditBalanceResponse;
    			
                // output balance
                int balance = (int)response.getBalance();
    			
                Console.WriteLine(String.Format("Your balance is: {0}.", balance));
            }
    		
            catch (Exception ex){
                System.WriteLine("Error: " + ex.Message);
            }
        }
    }
    
    Public Sub Test()
        ' specify error handler
        On Error GoTo errorHandler
        
        ' create request object
        Dim request As CreditBalanceRequest
        Set request = New CreditBalanceRequest
        
        ' set the request host domain
        request.setHost "api.smsonlinegh.com"
    
        ' By default requests will be sent using SSL/TLS with https connection.
        ' If you encounter SSL/TLS warning or error, your machine may be using unsupported
        ' SSL/TLS version. In that case uncomment the following line to set it to False
        ' request.useSecureConnectionEx False
        
        ' set authentication parameters
        request.setAuthModel AuthModel_API_KEY
        request.setAuthApiKey "d5c683a1b4c3d2f278be3d4c03c23191b2f133378b12b6e197c1ad5d9b34c128"
        
        ' get balance
        Dim response As CreditBalanceResponse
        Set response = request.submit
        
        ' output balance
        Debug.Print "Your balance is: " & " " & response.getBalance
        
        Exit Sub
        
        ' error handler
        errorHandler:
            MsgBox Err.Description
            Exit Sub
    End Sub
    
    Imports System
    
    Imports Zenoph.Notify.Enums
    Imports Zenoph.Notify.Request
    Imports Zenoph.Notify.Response
    
    Module Module1
        Sub Main()
            Try
                ' create the request object 
                Dim request as CreditBalanceRequest = new CreditBalanceRequest
    			
                ' set the request host domain
                request.setHost("api.smsonlinegh.com")
    			
                ' By default requests will be sent using SSL/TLS with https connection.
                ' If you encounter SSL/TLS warning or error, your machine may be using unsupported
                ' SSL/TLS version. In that case uncomment the following line to set it to False
                ' request.useSecureConnection(False)
    
                ' set authentication parameters
                request.setAuthModel(AuthModel.API_KEY)
                request.setAuthApiKey("d5c683a1b4c3d2f278be3d4c03c23191b2f133378b12b6e197c1ad5d9b34c128")
    
                ' get the balance
                Dim response As CreditBalanceResponse = request.submit()
    
                ' output balance
                Dim balance As Integer = Convert.ToInt32(response.getBalance())
    
                Console.WriteLine(String.Format("Your balance is: {0}.", balance))
    			
            Catch ex As Exception
                Console.WriteLine(String.Format("Error: {0}", ex.Message))
            End Try
        End Sub
    
    End Module
    
    import Zenoph.Notify.Enums.AuthModel;
    import Zenoph.Notify.Request.CreditBalanceRequest;
    import Zenoph.Notify.Response.CreditBalanceResponse;
    
    public class Test {
        public static void main(String[] args){
            try {
                // create the request object 
                CreditBalanceRequest request = new CreditBalanceRequest();
    			
                // set host
                request.setHost("api.smsonlinegh.com");
    			
                // By default requests will be sent using SSL/TLS with https connection.
                // If you encounter SSL/TLS warning or error, your machine may be using unsupported
                // SSL/TLS version. In that case uncomment the following line to set it to false
                // request.useSecureConnection(false);
    			
                // set authentication parameters
                request.setAuthModel(AuthModel.API_KEY);
                request.setAuthApiKey("d5c683a1b4c3d2f278be3d4c03c23191b2f133378b12b6e197c1ad5d9b34c128");
    			
                // get the balance
                CreditBalanceResponse response = (CreditBalanceResponse)request.submit();
    			
                // output balance
                int balance = (int)response.getBalance();
    			
                System.out.println(String.format("Your balance is: %d.", balance));
            }
    	
            catch (Exception ex){
                System.out.println("Error: " + ex.getMessage());
            }
        }
    }
    
    use Zenoph\Notify\Enums\AuthModel;
    use Zenoph\Notify\Request\CreditBalanceRequest;
        
    try {
        // create the request object 
        $request = new CreditBalanceRequest();
    	
        // set the request host domain
        $request->setHost('api.smsonlinegh.com');
    	
        // By default requests will be sent using SSL/TLS with https connection.
        // If you encounter SSL/TLS warning or error, your machine may be using unsupported
        // SSL/TLS version. In that case uncomment the following line to set it to false
        // $request->useSecureConnection(false);
    	
        // create request object
        $request = new CreditBalanceRequest();
        $request->setAuthModel(AuthModel::API_KEY);
        $request->setAuthApiKey('d5c683a1b4c3d2f278be3d4c03c23191b2f133378b12b6e197c1ad5d9b34c128');
    	
        // get the balance
        $response = $request->submit();
    	
        // output the balance
        $balance = $response->getBalance();
    	
        echo "Your balance is: {$balance}.";
    } 
    
    catch (Exception $ex) {
        die (printf("Error: %s.", $ex->getMessage()));
    }
    
    from Zenoph.Notify.Enums.AuthModel import AuthModel
    from Zenoph.Notify.Request.CreditBalanceRequest import CreditBalanceRequest
      
    try:
        # create the request object 
        request = CreditBalanceRequest()
    	  
        # set set the request host domain
        request.setHost("api.smsonlinegh.com")
    	  
        # By default requests will be sent using SSL/TLS with https connection.
        # If you encounter SSL/TLS warning or error, your machine may be using unsupported
        # SSL/TLS version. In that case uncomment the following line to set it to false
        # request.useSecureConnection(False)
    	  
        request.setAuthModel(AuthModel.API_KEY)
        request.setAuthApiKey('d5c683a1b4c3d2f278be3d4c03c23191b2f133378b12b6e197c1ad5d9b34c128')
    	  
        # get the balance
        response = request.submit()
    	  
        # output the balance
        print("Your balance is: " + response.getBalance())
    	  
    exception Exception as e:
        print("Error: " + str(e))
    

    If the test code above runs successfully and prints your current account balance, then your application can communicate with our messaging server. You are now ready to take a look into messaging.

    Back to top