You are here

function vkxp_query in VK CrossPoster 7

Same name and namespace in other branches
  1. 6.3 vkxp.module \vkxp_query()
  2. 6 vkxp.module \vkxp_query()
  3. 6.2 vkxp.module \vkxp_query()
  4. 7.2 vkxp.module \vkxp_query()

Function makes http query to vk.com. Allows using hook_vkxp_query_alter() for altering query params.

4 calls to vkxp_query()
vkxp_authorize in ./vkxp.pages.inc
Page callback. Processes request result from http://vk.com.
_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 260

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.com.
  // @TODO: try to change cURL support to drupal_http_request().
  $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 drupal_json_decode($result);
}