function vkxp_query in VK CrossPoster 7.2
Same name and namespace in other branches
- 6.3 vkxp.module \vkxp_query()
- 6 vkxp.module \vkxp_query()
- 6.2 vkxp.module \vkxp_query()
- 7 vkxp.module \vkxp_query()
Function makes http query to VK. Allows using hook_vkxp_query_alter() for altering query params.
4 calls to vkxp_query()
- vkxp_admin_access_token_submit in ./
vkxp.admin.inc - Second step of getting access token.
- _vkxp_get_upload_server in ./
vkxp.module - Makes http query to api server to get upload uri.
- _vkxp_post_to_wall in ./
vkxp.module - Post node message with uploaded images to wall.
- _vkxp_upload_images in ./
vkxp.module - Upload and save images to vk server.
File
- ./
vkxp.module, line 343
Code
function vkxp_query($method, $params, $request_url = VKXP_API_REQUEST_URI) {
// Collect query data.
$query = array();
$query['method'] = $method;
$query['params'] = $params;
$query['request_url'] = $request_url;
drupal_alter('vkxp_query', $query);
// cURL request to VK.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $query['request_url'] . '/' . $query['method']);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $query['params']);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
$res_decoded = json_decode($result);
// If we have errors in response - showing them to the site administrator.
foreach ($res_decoded as $item) {
if (!empty($item->error_code)) {
_vkxp_watchdog(array(
'text' => '[' . $item->error_code . '] :' . $item->error_msg,
'severity' => 'error',
));
}
}
curl_close($curl);
// Return request result.
return drupal_json_decode($result);
}