public function EntityShareClient::login in Entity Share 7
Login to the remote server.
Parameters
string $login: Login of the remote user.
string $password: Password of the remote user.
Return value
bool TRUE if success, FALSE otherwise.
File
- includes/
entity_share.client.inc, line 88 - Class for handling communication with Entity Share Server.
Class
- EntityShareClient
- Entity Share Client class.
Code
public function login($login, $password) {
// Call the login rest api.
$url = $this->endpointUrl . '/login';
$datas = drupal_json_encode(array(
'login' => $login,
'password' => $password,
));
$response = self::call($url, 'POST', $datas);
if (!empty($response->data) && $response->code == '200') {
$result = drupal_json_decode($response->data);
if (!empty($result['status']) && $result['status'] == 'OK') {
// Store session_name and session_id.
$this->sessionDatas['session_name'] = $result['result']['session_name'];
$this->sessionDatas['session_id'] = $result['result']['session_id'];
return TRUE;
}
}
return FALSE;
}