Supported Serialization Formats

The system supports all popular serialization formats. Below are example queries that use each of the supported formats, as well as their output.

Plain Text

For convenience, a plain text serialization format is provided, which is the default serialization format used if no other type is specified.


$ curl http://developer.vlab.co.in/auth_token/?token_id=abcd1234&format=text Output : yes
 

JSON

JSON is a popular serialization format. Here are two examples showing how to get results in JSON:


$ curl http://developer.vlab.co.in/auth_token/?token_id=abcd1234&format=json Output : { "response": "yes", "token":"abcd1234"}
 

JSONP

JSONP is a great choice if writing a JavaScript application, and to get actual JavaScript code returned by the API:


 
$ curl
http://developer.vlab.co.in/auth_token/?token_id=abcd1234&format=jsonp
Output : callback({"response": "yes", "token": "abcd1234" })
 
 
 
 
 
 
 

XML

Here are some examples showing how to get caller ID name data in XML format:

 
$ curl
http://developer.vlab.co.in/auth_token/?token_id=abcd1234&format=xml
Output : <?xml version='1.0' encoding='utf-8'?> <object><response>yes</response><token>abcd1234</token></object>
 
 

Example Implementation

Pseudo code

Request from VL Server to open ‘simulator.html ‘

_GET TOKEN from QUERY STRING Call http://developer.vlab.co.in/auth_token/?token_id=abcd1234 Wait for response If (response=yes) Send simulation content to server Else if (response=no OR time_out) Alert (Invalid token) End
 

GET TOKEN from QUERY STRING Call

http://developer.vlab.co.in/auth_token/?token_id=abcd1234 Wait for response If (response=yes)

Send simulation content to server Else if (response=no OR time_out) Alert (Invalid token) End

Apache-PHP Example Implementation


 
.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .
*\.(php|swf|html)$ / authenciate_response.php </IfModule> //create a .htaccess file in the subfolder of your server where the files for remote triggers are kept. The above .htacess code will redirect all php,swf and html file request inside this folder to the authenciate_response.php in the root folder.
 

Note: Enable curl in your server

authenciate_response.php

 

<?php
//getting the authentication token
 
$token_id=$_GET['token']; //if redirected using .htaceess file, this is to get the corresponding file name with path $fileName=$_SERVER['REQUEST_URI']; //sending the token to server for checking the validity of the token $ch = curl_init("http://developer.vlab.co.in/auth_token/?token=$token_id&format=text"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //getting the response from the server $response = curl_exec($ch); $response = trim($response); curl_close($ch); if($response=='yes') {
//if valid response show the remote trigger include($fileName);
} else {
echo "Invalid request!";
?>