3 # Sam Buca, indigo networks GmbH, 08/2007
5 # This script is a very basic perl-client to the SAMURAI service
6 # provided by sipgate (indigo networks GmbH) without any claim to
7 # completeness and without any warranty!
9 # The following code shows how to use the service to send messages
10 # via SMS using a sipgate account.
14 use Frontier
::Client
; # needed for XMLRPC
16 # declare some variables for later use:
18 my $NAME = "sipgateAPI-sms.pl";
19 my $VENDOR = "indigo networks GmbH";
26 # check the count of commandline parameters and show usage information
30 print "This script needs 4 parameters supplied on the commandline:\n";
32 print "parameter 1 -> the username (not SIPID) used to login to sipgate\n";
33 print "parameter 2 -> the password associated with the username\n";
34 print "parameter 3 -> the number to send the message to\n";
35 print " (with national prefix, e.g. 4917xxxxxxxxx)\n";
36 print "parameter 4 -> the message to send quoted in \" or \'\n";
42 # define URL for XMLRPC:
44 $url = "https://$ARGV[0]:$ARGV[1]\@samurai.sipgate.net/RPC2";
46 # create an instance of the XMLRPC-Client:
48 $xmlrpc_client = Frontier
::Client
->new( 'url' => $url );
50 # identify the script to the server calling XMLRPC-method "samurai.ClientIdentify"
51 # providing client-name, -version and -vendor:
53 $args_identify = { ClientName
=> $NAME, ClientVersion
=> $VERSION, ClientVendor
=> $VENDOR };
55 $xmlrpc_result = $xmlrpc_client->call( "samurai.ClientIdentify", $args_identify );
57 # the check for success is not necessary in this case since the Frontier::Client module
58 # dies with an exception in case of a fault, but we do it for completeness:
60 if ($xmlrpc_result->{'StatusCode'} == 200) {
61 print "Successfully identified to the server!\n";
63 # we should never get here!
64 print "There was an error during identification to the server!\n";
67 # create the input argument set for XMLRPC:
69 $args = { RemoteUri
=> "sip:$ARGV[2]\@sipgate.net", TOS
=> "text", Content
=> $ARGV[3] };
71 # do the call and store the result / answer to $xmlrpc_result:
73 $xmlrpc_result = $xmlrpc_client->call( "samurai.SessionInitiate", $args );
75 # again we do the check on success for completeness:
77 if ($xmlrpc_result->{'StatusCode'} == 200) {
78 print "Your request was successfully send to the server!\n";
80 # we should never get here!
81 print "There was an error!\n";