forked from AndreasFischer1985/ausbildungssuche-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_example.php
36 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
<?php
// POST-request:
//--------------
$url = 'https://rest.arbeitsagentur.de/oauth/gettoken_cc';
$data = array(
'client_id' => '1c852184-1944-4a9e-a093-5cc078981294',
'client_secret' => '777f9915-9f0d-4982-9c33-07b5810a3e79',
'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/absuche/pc/v1/ausbildungsangebot?'.$_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;
}
?>