Difference between revisions of "API:Core"

From TheHostingTool Wiki
Jump to navigationJump to search
Line 19: Line 19:
 
To create your auth hash, you need to generate a sha512 hash and two sha1 hashes. The two sha1 hashes are generated, joined together, and are then used to create a sha512 hash. Your hashing code should look like this:
 
To create your auth hash, you need to generate a sha512 hash and two sha1 hashes. The two sha1 hashes are generated, joined together, and are then used to create a sha512 hash. Your hashing code should look like this:
 
<pre>$hash = hash('sha512', sha1('function_name|parameters') . sha1($my_tht_api_key));</pre>
 
<pre>$hash = hash('sha512', sha1('function_name|parameters') . sha1($my_tht_api_key));</pre>
<br />
+
 
 
===If not using a parameter===
 
===If not using a parameter===
 
So now let's get a list of users. We'll assume you already have your API key. Now, the hashing and access method change. To generate a hash:
 
So now let's get a list of users. We'll assume you already have your API key. Now, the hashing and access method change. To generate a hash:

Revision as of 01:47, 15 February 2010

Setting Up an Authentication Key

Use the Gallery for information:

Calling a Function

The API uses a REQUEST system -- this means you can submit your variables via POST or GET. Requests are made to xml-api/index.php. The xml-api directory will be found in the THT directory. For these examples, we will be using PHP as our language for coding a script to get a list of accounts. For simplicity, we will be using a GET request.

You will need to create a hash of the function.

If using a parameter

To call a function with a parameter using the XML-API, you would make a request to:

http://mydomain.tld/THT_DIR/xml-api/function/params/auth_hash

To create your auth hash, you need to generate a sha512 hash and two sha1 hashes. The two sha1 hashes are generated, joined together, and are then used to create a sha512 hash. Your hashing code should look like this:

$hash = hash('sha512', sha1('function_name|parameters') . sha1($my_tht_api_key));

If not using a parameter

So now let's get a list of users. We'll assume you already have your API key. Now, the hashing and access method change. To generate a hash:

$hash = hash('sha512', sha1('listaccts') . sha1($my_tht_api_key));

And the request URL would be:

http://mydomain.tld/THT_DIR/xml-api/function/auth_hash