| <?php
|
|
|
| require 'OnetWebService.php';
|
|
|
|
|
| $input = json_decode(stream_get_contents(STDIN));
|
|
|
|
|
| $onet_ws = new OnetWebService($input->config->username, $input->config->password);
|
| $max_results = max(1, $input->config->max_results);
|
| $output = [ 'output' => [] ];
|
|
|
|
|
| foreach ($input->queries as $q) {
|
| $res = [];
|
| $kwresults = $onet_ws->call('online/search',
|
| [ 'keyword' => $q,
|
| 'end' => $max_results ]);
|
| if (property_exists($kwresults, 'occupation') && count($kwresults->occupation)) {
|
| foreach ($kwresults->occupation as $occ) {
|
| $res[] = [ 'code' => $occ->code, 'title' => $occ->title ];
|
| }
|
| }
|
| $output['output'][] = [ 'query' => $q, 'results' => $res ];
|
| }
|
|
|
| echo json_encode($output, JSON_PRETTY_PRINT);
|
|
|
| ?>
|
|
|