You are here

function vkxp_query in VK CrossPoster 6.3

Same name and namespace in other branches
  1. 6 vkxp.module \vkxp_query()
  2. 6.2 vkxp.module \vkxp_query()
  3. 7.2 vkxp.module \vkxp_query()
  4. 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 256

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);
  curl_close($curl);

  // Return request result.
  return json_decode($result, TRUE);
}