forked from AndreasFischer1985/entgeltatlas-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_example.php
37 lines (34 loc) · 1.09 KB
/
api_example.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
<?php
// POST-request:
//--------------
$url = 'https://rest.arbeitsagentur.de/oauth/gettoken_cc';
$data = array(
'client_id' => 'c4f0d292-9d0f-4763-87dd-d3f9e78fb006',
'client_secret' => '566c4dd6-942f-4cda-aad6-8d611c577107',
'grant_type' => 'client_credentials');
$options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$tokendata = file_get_contents($url, false, $context);
header('Content-Type: application/json');
if(isset($_GET['token']) & $_GET['token']==='TRUE'){
echo $tokendata;
} else {
// GET-request:
//-------------
$url = 'https://rest.arbeitsagentur.de/infosysbub/entgeltatlas/pc/v1/entgelte/84304?'.$_SERVER['QUERY_STRING'];
$options = array(
'http' => array(
'header' => "OAuthAccessToken:".json_decode($tokendata, true)['access_token']." \r\n",
'method' => 'GET'
)
);
$context = stream_context_create($options);
$searchdata = file_get_contents($url, false, $context);
echo $searchdata;
}
?>