8.7.3.1 Login
Connection URL
TEST URL | http://nap.dev.icash.bg/clientapi/v1/login |
PRODUCTION URL | https://v5.icash.bg/clientapi/v1/login |
POST Request params
Param | Description | Type | Required |
api_key | API Key | String | YES |
nonce | Nonce | Integer | YES |
signature | Signature | String | YES |
WareHouseID | Warehouse ID | Integer | YES |
UserID | User ID | Integer | YES |
JSON Result on success
Param | Description | Type | Required |
nonce | Nonce from request | Integer | YES |
status | Status | Integer
1 – on success |
YES |
data | Result | result | YES |
Example: { "nonce": "1552989761", "status": 1, "data": { "session_id": "66a891e8b4d7d018d230363bcd0adfbd" } }
JSON Result on fail
Param | Description | Type | Required |
nonce | Nonce от заявката | Integer | Да |
status | Статус на заявката | Integer
0 – on fail |
Да |
error_message | Описание на грешката | String | Да |
Example: { "nonce": "1552990302", "status": 0, "error_message": "Authentication Error" } Sample code PHP: <?php //initial params $g_cnt=0; // additional counter for nonce $url="https://v5.nap.dev.icash.bg/clientapi/v1/login"; $api_key='5kdkuujr8l50iv6yp504qxn2grnlhm2h'; // from user settings $secret_key='0ptpe0rekdtasktyj1nhjxhzbz1bk5n3'; // from user settings $WareHouseID="785"; // warehouse ID $UserID="1"; // from user list // calculate signature $nonce=time()+$g_cnt; // create always unique and increment value $message = $nonce.$WareHouseID.$api_key; $signature = strtoupper(bin2hex(hash_hmac('sha256',$message, $secret_key,true))); $fields = [ 'api_key' => $api_key, 'nonce' => $nonce, 'signature' => $signature, 'WareHouseID' => $WareHouseID, 'UserID' => $UserID ]; $fields_string = http_build_query($fields); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $ret=json_decode($result); // check result var_export($ret); ?>