Method: loginUser

This method allows you to create an authenticated session to be able to use methods which need authentication.

Authentication

This method does require authentication using valid login/password.

HTTP method

This method is called with HTTP method GET.

Arguments

Argument Type Element (array) Valid Values Default Value Detail
username string   existing login required User Login
userpass string   password corresponding to login required User Password
token string   authenticated session id (stored in the session $_SESSION['token'], it is empty when not authenticated) empty User Token

Returned Values

Element (path) Name Type Description
/ token string authenticated session id (needed for methods needed authentication)
/ text array
Token : [token]   or  You are not logged!
You are logged! ERROR: Your Username or Password is not correct!

Example Query

	GET http://testapi.wannaprint.com/Rest/1/[API Key]/api/loginUser/username=[username]&userpass=[password]&token=[token]

PHP call of method:
	<?php
		session_start();
		$api_items = $apicaller->sendRequest(array(
					'controller' => 'api',
					'action' =>  'loginUser',
					'username' =>  '[username]',
					'userpass' =>  '[password]',
					'token' =>  ''
					)); 
		foreach($api_items->text as $text)
		{
			echo $text;
		}
		$_SESSION['token'] = $api_items->token;
	?>
   			

Example Response

	{
		"text":[
			"Token : [token]",
			"You are logged!"
		],
		"token": "SESSION_TOKEN"
	}

						or

	{
		"text":["You are not logged!"]
	}
   			

Error Codes

001: Wrong API Key
The API key is wrong or missing.
002: Failed to parse request
The request could not be parsed.
011: Controller is invalid.
The controller passed is not valid.
031: Invalid Method
This method does not exist in the method list.