ItTrust API

Intro

Each request must be send via $_POST and must have the token parameter included. Click to see how to generate token

The ItTrust APi have two types of request:
1 - returning user ids.
2 - returning user details for specific ID

The returned format is XML

Each request return an XML that will contain :
1.Status - that contains

  • current date
  • status type:succes or failed
1.Data - that contains the returned results.

Get ids request

Where to send the request for getting the ids?

-http://api.ittrust.ro/getIDs.php
Bellow you'll find the list of parameters that you cand send them:
1.token - required
2.lastID - optional
  • the list will be returned starting from lastID parameter defined by you
  • default value:0
3.limit - optional
  • if you want to specify the number of records to return.
  • default value:1000
  • maximum value:1000

Code snippet

                                            
                                                < ?php
                                                header("Content-type: text/xml");
                                                $url = 'http://api.ittrust.ro/getIDs.php';
                                                $data['token']="bGllcGFyb2xh";//required -your encoded string
                                                $data['limit']="10";//optional 
                                                $data['lastID']=4852;//optional
                                                $handle = curl_init($url);
                                                curl_setopt($handle, CURLOPT_POST, true);
                                                curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
                                                curl_setopt($handle, CURLOPT_POSTFIELDS, http_build_query($data));
                                                $xmlstring = curl_exec($handle);//the xmlfile
                                                 //////////////////// xml to array
                                                $xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
                                                $json = json_encode($xml);
                                                $array = json_decode($json,TRUE);


                                                ?>

                                            
                                        

Get user details

Where to send the request for getting the user details?

-http://api.ittrust.ro/getUser.php
Bellow you'll find the list of parameters that you cand send them:
1.token - required
2.userID - required
  • numeric only

Code snippet

                                            
                                                < ?php
                                                header("Content-type: text/xml");
                                                $url = 'http://api.ittrust.ro/getUser.php';
                                                $data['token']="bGllcGFyb2xh";//required -your encoded string
                                                $data['userID']="10";//required 
                                                $handle = curl_init($url);
                                                curl_setopt($handle, CURLOPT_POST, true);
                                                curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
                                                curl_setopt($handle, CURLOPT_POSTFIELDS, http_build_query($data));
                                                $xmlstring = curl_exec($handle);//the xmlfile
                                                 //////////////////// xml to array
                                                $xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
                                                $json = json_encode($xml);
                                                $array = json_decode($json,TRUE);


                                                ?>

                                            
                                        
...

Generating token

We support basic authorization using a username and password with Base64 encoding variation RFC2045-MIME.
The authorization token is constructed as follows:

Username and password are combined into a string username:password
When you encode check to have the colon sign included)
. The resulting string is encoded using the RFC2045-MIME variant of Base64. Bellow you have an example :
                                            
                                                < ?php
                                                $username = "myusername";
                                                $password = "myPassword";
                                                //now we will generate the token
                                                $myToken=base64_encode($username.":".$password);

                                                ?>
                                            
                                        
Now we have to include the generated token on each request we send.