You are here

function _dsq_curl_urlopen in Drupal Most Popular 7

1 call to _dsq_curl_urlopen()
dsq_urlopen in modules/mostpopular_disqus/disqusapi/url.php
Wrapper to provide a single interface for making an HTTP request.

File

modules/mostpopular_disqus/disqusapi/url.php, line 62

Code

function _dsq_curl_urlopen($url, $postdata, &$response, $file_name, $file_field) {
  $c = curl_init($url);
  $postdata_str = dsq_get_query_string($postdata);
  $c_options = array(
    CURLOPT_USERAGENT => USER_AGENT,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => $postdata_str ? 1 : 0,
    CURLOPT_HTTPHEADER => array(
      'Expect:',
    ),
    CURLOPT_TIMEOUT => SOCKET_TIMEOUT,
  );
  if ($postdata) {
    $c_options[CURLOPT_POSTFIELDS] = $postdata_str;
  }
  if ($file_name && $file_field) {
    $postdata[$file_field] = '@' . $file_name;
    $c_options[CURLOPT_POSTFIELDS] = $postdata;
    $c_options[CURLOPT_RETURNTRANSFER] = 1;
  }
  curl_setopt_array($c, $c_options);
  $response['data'] = curl_exec($c);
  $response['code'] = curl_getinfo($c, CURLINFO_HTTP_CODE);
}