Difference between revisions of "PHP Integration Sample"

From Boxis.net API Docs
Jump to: navigation, search
(Created page with "=PHP Integration Sample= Some text here.... + URL to download the PHP Class =Example1= =Example2=")
 
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=PHP Integration Sample=
 
=PHP Integration Sample=
  
Some text here.... + URL to download the PHP Class
+
Boxis.net API is simple to implement using any programming language available that can communicate remotely to our system. We have created simple communication class for the PHP. Yet, you can create your own based on the one we have provided.
  
  
=Example1=
+
[http://www.boxis.net/xmlapi/examples/getFile.php Download Class]
  
=Example2=
+
=== Example 1 - Domains API ===
 +
 
 +
This is simple example how to use our API with the class.boxisAPI.php
 +
 
 +
<pre>
 +
/* API LOGIN DETAILS */
 +
$email    = 'your@email.com';    // your username
 +
$apikey  = '1234567890';        // your apikey
 +
 
 +
/* API COMMAND DETAILS */
 +
$apitype  = 'domains';
 +
$command  = 'register';
 +
$params  = array(
 +
    'returntype' => 'xml',  // xml or json
 +
    'domain' => 'test1.com',
 +
    'years' => 2,
 +
    'ns' => array('203.234.12.34', '88.23.23.44'),
 +
    'protect-privacy' => 1
 +
);
 +
 
 +
/* PROCESS THE ACTION */
 +
$boxisAPI = new BoxisAPIConnection($email, $apikey);
 +
$return = $boxisAPI->call($apitype, $command, $params, $timestamp);
 +
 
 +
/* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE)
 +
if($return['timestamperror']) {
 +
    $timestamp = $return['timestamp'];
 +
    $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp);
 +
}
 +
*/
 +
 
 +
/* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/
 +
/*
 +
if($return->timestamperror) {
 +
    $timestamp = $return->timestamp;
 +
    $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp);
 +
}
 +
/*
 +
 
 +
/* RETURNED VALUE */
 +
echo htmlspecialchars($return);
 +
</pre>
 +
 
 +
'''Which will output:'''
 +
 
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<return>
 +
  <result>1</result>
 +
  <resulttxt>success</resulttxt>
 +
  <params/>
 +
  <timestamp>1337942776</timestamp>
 +
</return>
 +
</pre>
 +
 
 +
=== Example 2 - SMS API ===
 +
 
 +
This is simple example how to use our API with the class.boxisAPI.php
 +
'''Which will output:'''
 +
<pre>
 +
/* API LOGIN DETAILS */
 +
/* API LOGIN DETAILS */
 +
$email    = 'your@email.com';    // your username
 +
$apikey  = '1234567890';        // your apikey
 +
 
 +
/* API COMMAND DETAILS */
 +
$apitype  = 'sms';
 +
$command  = 'sendSMS';
 +
$params  = array(
 +
    'returntype' => 'json',  // json or xml
 +
    'sender_name' => 'boxis.net',
 +
    'recipients' => array('48599131568'),
 +
    'content' => 'test1',
 +
);
 +
 
 +
/* PROCESS THE ACTION */
 +
$boxisAPI = new BoxisAPIConnection($email, $apikey);
 +
$return = $boxisAPI->call($apitype, $command, $params, $timestamp);
 +
 
 +
/* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE)
 +
if($return['timestamperror']) {
 +
    $timestamp = $return['timestamp'];
 +
    $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp);
 +
}
 +
*/
 +
 
 +
/* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/
 +
/*
 +
if($return->timestamperror) {
 +
    $timestamp = $return->timestamp;
 +
    $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp);
 +
}
 +
/*
 +
 
 +
/* RETURNED VALUE */
 +
print_r($return);
 +
</pre>
 +
 
 +
'''Which will output:'''
 +
 
 +
<pre>
 +
stdClass Object ( [result] => 1 [resulttxt] => success [params] => stdClass Object ( [sms_id] => 133794570431563000005480 ) [timestamp] => 1337945704 ) 
 +
</pre>

Latest revision as of 11:19, 25 June 2012

PHP Integration Sample

Boxis.net API is simple to implement using any programming language available that can communicate remotely to our system. We have created simple communication class for the PHP. Yet, you can create your own based on the one we have provided.


Download Class

Example 1 - Domains API

This is simple example how to use our API with the class.boxisAPI.php

/* API LOGIN DETAILS */
$email    = 'your@email.com';    // your username
$apikey   = '1234567890';        // your apikey

/* API COMMAND DETAILS */
$apitype  = 'domains';
$command  = 'register';
$params   = array(
    'returntype' => 'xml',  // xml or json
    'domain' => 'test1.com',
    'years' => 2,
    'ns' => array('203.234.12.34', '88.23.23.44'),
    'protect-privacy' => 1
);

/* PROCESS THE ACTION */
$boxisAPI = new BoxisAPIConnection($email, $apikey);
$return = $boxisAPI->call($apitype, $command, $params, $timestamp);

/* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE)
if($return['timestamperror']) {
    $timestamp = $return['timestamp'];
    $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp);
}
*/

/* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/
/*
if($return->timestamperror) {
    $timestamp = $return->timestamp;
    $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp);
}
/*

/* RETURNED VALUE */
echo htmlspecialchars($return);

Which will output:

<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>1</result>
  <resulttxt>success</resulttxt>
  <params/>
  <timestamp>1337942776</timestamp>
</return>

Example 2 - SMS API

This is simple example how to use our API with the class.boxisAPI.php Which will output:

/* API LOGIN DETAILS */
/* API LOGIN DETAILS */
$email    = 'your@email.com';    // your username
$apikey   = '1234567890';        // your apikey

/* API COMMAND DETAILS */
$apitype  = 'sms';
$command  = 'sendSMS';
$params   = array(
    'returntype' => 'json',  // json or xml
    'sender_name' => 'boxis.net',
    'recipients' => array('48599131568'),
    'content' => 'test1',
);

/* PROCESS THE ACTION */
$boxisAPI = new BoxisAPIConnection($email, $apikey);
$return = $boxisAPI->call($apitype, $command, $params, $timestamp);

/* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE)
if($return['timestamperror']) {
    $timestamp = $return['timestamp'];
    $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp);
}
*/

/* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/
/*
if($return->timestamperror) {
    $timestamp = $return->timestamp;
    $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp);
}
/*

/* RETURNED VALUE */
print_r($return);

Which will output:

stdClass Object ( [result] => 1 [resulttxt] => success [params] => stdClass Object ( [sms_id] => 133794570431563000005480 ) [timestamp] => 1337945704 )