function rec_transfer_check_service in Recommender API 7.5
Same name and namespace in other branches
- 6.3 rec_transfer/rec_transfer.module \rec_transfer_check_service()
- 7.4 rec_transfer/rec_transfer.module \rec_transfer_check_service()
3 calls to rec_transfer_check_service()
- rec_transfer_download in rec_transfer/
rec_transfer.module - rec_transfer_handle_commands in rec_transfer/
rec_transfer.module - rec_transfer_upload in rec_transfer/
rec_transfer.module
File
- rec_transfer/
rec_transfer.module, line 229 - This is the module file for Recommender Data Transfer
Code
function rec_transfer_check_service($what, $options = array()) {
// since we are using CURL anyway, we'll use CURL instead of drupal_http_request
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Drupal (Recommender)");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, variable_get('rec_transfer_endpoint') . '/check');
$post = array(
'apikey' => variable_get('rec_transfer_apikey'),
'what' => $what,
) + $options;
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
//var_dump($response);
$data = drupal_json_decode($response);
$results = array(
'success' => $response && curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200,
'http_code' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
'response' => $response,
'data' => $data,
'message' => '',
);
if ($response == FALSE) {
$results['message'] = 'Cannot connect to the service.';
}
else {
if (isset($data['status'])) {
$results['status'] = $data['status'];
}
$results['message'] = $data['message'];
}
curl_close($ch);
return $results;
}