/*----------------------------------------------------------
| FUNCTION : call_webservice($parameters = array(), $jsonType = 0)
| DESCRIPTION : Fonction de consommation du service web
| INPUT : Accepte 2 parameteres :
+ param 1 : tableau contenant les parameters de l'action
+ param 2 : le type du json retourné (0 = standard, 1 = compact)
| OUTPUT : json
| ----------------------------------------------------------
| Note : Ne pas modifier cette fonction
| ----------------------------------------------------------
*/
function call_webservice($action, $parameters = array(), $jsonType = 0) {
//Parameters to post to webservice
$paramsToPost = array();
$paramsToPost['user'] = WS_USER_NAME;
$paramsToPost['hash'] = WS_CLE_SECURITE;
$paramsToPost['action_parameters'] = $parameters;
$paramsToPost['responseJsonType'] = $jsonType;
//+++++++++++++++++++++++++++++++++++++ Prepare Request +++++++++++++++++++++++++++++++++++++++++++++++//
$opts = array(
'http' => array(
'header' => array("Content-type: application/x-www-form-urlencoded"),
'method' => 'POST',
'content' => http_build_query($paramsToPost),
)
);
//+++++++++++++++++++++++++++++++++++++ Send Request ++++++++++++++++++++++++++++++++++++++++++++++++++//
$context = stream_context_create($opts);
$response = file_get_contents(WS_ADDRESS_URL.$action, false, $context);
//+++++++++++++++++++++++++++++++++++++ return response json ++++++++++++++++++++++++++++++++++++++++++++++//
var_dump($response);
$response = json_decode($response);
return $response;
}
// Exemple d'appel du webservice pour le jobboard
$action = 'jobs';
$action_parameters = array('JobId' => null, // put null to return all jobs
'IncludePermanent' => 1, // permanent jobs
'IncludeContract' => 1, // contractual jobs
'FilterFunction' => null, //cgrcod,cchcod,niveau;cgrcod,cchcod,niveau;...,
'FilterRegion' => '', //cgrcod,cchcod,niveau;cgrcod,cchcod,niveau;...,
'Language' => 'FR', //FR, ENG
'ClientWebSite' => null,
'FilterWordTitle' => '',
'FilterDivision' => null,
);
// Appel du webservice
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$response = call_webservice($action, $action_parameters);
$result = json_decode($response);
$data = json_decode($result->data);
echo '<pre>';
print_r($data);
echo '</pre>';
?>
|