Log in to your CO3 account with a user who has Super Admin rights. Go to the Users & Settings tab then select Account settings. In the Account data section you can see your account name and your API key.
Create an XML or JSON which you will POST to the API. The password must be MD5 hashed!
api_key (string): API Key for the account.username (string): The user's username.password (string): The user's password, which must be MD5 hashed.Sample request XML.
<?xml version="1.0" encoding="utf-8"?>
<command>
<authenticate>
<api_key><![CDATA[put-your-api-key-here]]></api_key>
<username><![CDATA[put-username-here]]></username>
<password><![CDATA[put-password-here-with-md5]]></password>
</authenticate>
</command>
Sample request JSON.
{
"command": {
"authenticate": {
"api_key": "put-your-api-key-here",
"username": "put-username-here",
"password": "put-password-here-with-md5"
}
}
}
Follow the steps below to get your session key.
$opts = array(
'http' => array(
'method' => 'POST',
'header' => array(
'Connection: close',
'Content-Type: text/xml; charset=utf-8',
'Content-Length: '.strlen($xml)
),
'content' => $xml
)
);
$context = stream_context_create($opts);
$response = file_get_contents("https://co3app.com/api/authenticate", false, $context);
echo $response;
The response will be your session key. The session key is valid for 5 minutes and you have to use it in all of your requests!
The session key is belongs to the authenticated user. In this case the user rights will be used in the session.