This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhanze.php
47 lines (43 loc) · 1.58 KB
/
hanze.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
class Hanze
{
private $hanzeUser;
private $hanzePasswd;
public function __construct($username, $password)
{
$this->hanzeUser = $username;
$this->hanzePasswd = $password;
}
public function getToken()
{
// The request should atleast contain the following fields
// curl:Z2F_layoutsZ2F15Z2FAuthenticate.aspxZ3FSourceZ3DZ2Fnld
// flags:0
// forcedownlevel:0
// formdir:3
// username:<xxx>
// password:<password>
// SubmitCreds:Aanmelden
// trusted:0
$client = new \GuzzleHttp\Client(['cookies' => true]);
$response = $client->request('POST', $_ENV['HANZE_LOGON_URL'], [
'headers' => [
'Origin' => 'https://www.hanze.nl',
'Refer' => 'https://www.hanze.nl/CookieAuth.dll?GetLogon?curl=Z2F_layoutsZ2F15Z2FAuthenticate.aspxZ3FSourceZ3DZ2Fnld&reason=0&formdir=3',
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
],
'allow_redirects' => false,
'form_params' => [
'curl' => 'Z2F_layoutsZ2F15Z2FAuthenticate.aspxZ3FSourceZ3DZ2Fnld',
'flags' => 0,
'forcedownlevel' => 0,
'formdir' => 3,
'username' => $_ENV['HANZE_USERNAME'],
'password' => $_ENV['HANZE_PASSWORD'],
'SubmitCreds' => 'Aanmelden',
'trusted' => 0
]
]);
return $client;
}
}