SoftNAS API Guide
Menu
Index

3.4. login

 
Description
 
Using this method, you can POST a login request to the SoftNAS API, creating an active session with the SoftNAS Admin Server.
 
POST login username password
 
Request
 
Login is based on the Standard Request Structure
 
For parameter definitions, see section Properties
 
Property
Required?
Note
username
Y
 
password
Y
 
Session ID
N
 
Base URL
N
 
Pretty Print
N
 
 
Example
 
Login using PHP.
 
<?php
 
    $mypath = getcwd();
 
    $mypath = preg_replace('/\\\\/', '/', $mypath);
 
    $rand = rand(1, 15000);
 
    $cookie_file_path = "$mypath/cookies/cookie$rand.txt";
 
    $data = array(
 
     'username' => 'softnas',
 
     'password' => 'Pass4W0rd'
 
     );
 
 
 
    $ch = curl_init();
 
    curl_setopt($ch, CURLOPT_URL, "https://example.com/softnas/login.php");
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
    curl_setopt($ch, CURLOPT_POST, true);
 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);   // Cookie management.
 
 
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
 
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
 
 
 
    $output = curl_exec($ch);
 
    $info = curl_getinfo($ch);
 
    curl_close($ch);
 
    echo $info;
 
 
 
 
 
Return Values
 
 
Example Output
 
{
"result": {},
"session_id": 8062, 
"success": true
}
 
 
Made with help of Dr.Explain