function _linkedin_put_profile_field in LinkedIn Integration 7
@todo Please document this function.
See also
1 call to _linkedin_put_profile_field()
- linkedin_put_profile_field in ./
linkedin.module - @todo Please document this function.
File
- ./
linkedin.inc, line 272
Code
function _linkedin_put_profile_field($uid, $body, $api = 'shares') {
//Get sure library is loaded before doing anything.
linkedin_init();
$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_query("SELECT * FROM {linkedin_token} WHERE uid = :uid AND type = :type", array(
':uid' => $uid,
':type' => 'access',
))
->fetchAssoc();
$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;
}