You are here

function linkedin_get_fields in LinkedIn Integration 6

Same name and namespace in other branches
  1. 7 linkedin.module \linkedin_get_fields()
1 call to linkedin_get_fields()
linkedin_get_profile_fields in ./linkedin.inc

File

./linkedin.inc, line 211

Code

function linkedin_get_fields($url, $tokens) {
  $signature = new OAuthSignatureMethod_HMAC_SHA1();
  $consumer_key = variable_get('linkedin_consumer_key', '');
  $consumer_secret = variable_get('linkedin_consumer_secret', '');
  $consumer = new OAuthConsumer($consumer_key, $consumer_secret, NULL);
  $token = new OAuthConsumer($tokens['token_key'], $tokens['token_secret'], 1);
  $request = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", $url);
  $request
    ->sign_request($signature, $consumer, $token);
  $header = $request
    ->to_header("https://api.linkedin.com");
  $response = _linkedin_http_request($url, $header);
  parse_str($response);
  $response = _linkedin_parse_fields($response);
  if (isset($response['error-code'])) {
    $message = t('Linkedin debug : LinkedIn.com answered "@status : @message', array(
      '@status' => $response['status'],
      '@message' => $response['message'],
    ));
    if (variable_get('linkedin_debug_mode', 0) == 1) {
      drupal_set_message($message, 'warning');
    }
    watchdog('warning', $message);
  }
  return $response;
}