function linkedin_put_profile_field in LinkedIn Integration 6
Same name and namespace in other branches
- 7 linkedin.module \linkedin_put_profile_field()
1 call to linkedin_put_profile_field()
- linkedin_status_li_set_status in linkedin_status/
linkedin_status.module - Implementation of hook_li_set_status()
File
- ./
linkedin.inc, line 240
Code
function linkedin_put_profile_field($uid, $body, $api = 'shares') {
$base_url = 'https://api.linkedin.com/v1/people/~/';
$url = $base_url . $api;
if ($api == 'shares') {
$xml = '<share>';
if (isset($body['comment'])) {
$xml .= '<comment>' . $body['comment'] . '</comment>';
}
if (isset($body['title']) && isset($body['submitted-url'])) {
$xml .= '<content>';
$xml .= '<title>' . $body['title'] . '</title>';
$xml .= '<submitted-url>' . $body['submitted-url'] . '</submitted-url>';
if (isset($body['submitted-image-url'])) {
$xml .= '<submitted-image-url>' . $body['submitted-image-url'] . '</submitted-image-url>';
}
if (isset($body['description'])) {
$xml .= '<description>' . $body['description'] . '</description>';
}
$xml .= '</content>';
}
$xml .= '<visibility><code>anyone</code></visibility>';
$xml .= '</share>';
}
else {
// Unsupported update method
$message = t('Linkedin debug : Unsupported update method "@method"', array(
'@method' => $api,
));
if (variable_get('linkedin_debug_mode', 0) == 1) {
drupal_set_message($message, 'warning');
}
watchdog('warning', $message);
return;
}
$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);
$row = db_fetch_array(db_query("SELECT * FROM {linkedin_token} WHERE uid = %d AND type = 'access'", $uid));
$token = new OAuthConsumer($row['token_key'], $row['token_secret'], 1);
$request = OAuthRequest::from_consumer_and_token($consumer, $token, 'POST', $url, array());
$request
->sign_request($signature, $consumer, $token);
$header = $request
->to_header();
$response = _linkedin_http_request($url, $header, $xml);
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;
}