forked from bundesAPI/jobsuche-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_example.php
More file actions
36 lines (34 loc) · 1.09 KB
/
api_example.php
File metadata and controls
36 lines (34 loc) · 1.09 KB
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' => 'c003a37f-024f-462a-b36d-b001be4cd24a',
'client_secret' => '32a39620-32b3-4307-9aa1-511e3d7f48a8',
'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/jobboerse/jobsuche-service/pc/v4/jobs?'.$_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;
}
?>