You are here

function _linkedin_get_fields in LinkedIn Integration 7

@todo Please document this function.

See also

http://drupal.org/node/1354

1 call to _linkedin_get_fields()
linkedin_get_fields in ./linkedin.module
@todo Please document this function.

File

./linkedin.inc, line 235

Code

function _linkedin_get_fields($url, $tokens) {

  //Get sure library is loaded before doing anything.
  linkedin_init();
  $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;
}