-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNutagAPI.php
More file actions
32 lines (26 loc) · 853 Bytes
/
NutagAPI.php
File metadata and controls
32 lines (26 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require __DIR__.'/lib/IFRN_User.php';
class NutagAPI
{
public function authUser($matricula, $senha) {
$data = array("matricula"=> $matricula, "senha"=>$senha);
$url = "https://nutag.websiteseguro.com/api/auth/";
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$result = json_decode($result);
if (isset($result->type) && $result->type=="error") {
return false;
} else {
$user = new IFRN_User($matricula, $result->nome, $result->sobrenome, $result->email);
return array("type"=>"success", "msg"=>"user_ok", "user"=>$user);
}
}
}
?>