-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtoken.php
More file actions
32 lines (25 loc) · 889 Bytes
/
token.php
File metadata and controls
32 lines (25 loc) · 889 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
$openapi_username = "[email protected]";
$openapi_apikey = "39d4122862f2619981518e418aa2f053";
$openapi_scopes = array( "GET:test.ws.ufficiopostale.com/raccomandate");
$openapi_request = array("scopes"=>$openapi_scopes);
$basic_auth = base64_encode("$openapi_username:$openapi_apikey");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://test.oauth.altravia.com/token/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($openapi_request),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Basic '.$basic_auth
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;