You are here

function _linkedin_http_request in LinkedIn Integration 6

Same name and namespace in other branches
  1. 7 linkedin.inc \_linkedin_http_request()
3 calls to _linkedin_http_request()
linkedin_access_token in ./linkedin.inc
linkedin_get_fields in ./linkedin.inc
linkedin_put_profile_field in ./linkedin.inc

File

./linkedin.inc, line 297

Code

function _linkedin_http_request($url, $header, $body = NULL) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    $header,
  ));
  curl_setopt($ch, CURLOPT_URL, $url);
  if ($body) {
    curl_setopt($ch, CURLOPT_POST, 1);
    if ($body == 'token_request') {
      curl_setopt($ch, CURLOPT_POSTFIELDS, '');
    }
    else {
      curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        $header,
        'Content-Type: text/xml;charset=utf-8',
      ));
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    }
  }
  $output = curl_exec($ch);
  curl_close($ch);
  return $output;
}