public function SocialContentLinkedin::getRows in Social Content 7.2
Get the rows to import.
Parameters
mixed $last_id: The id of the last import.
Return value
array Array with the rows.
Overrides SocialContent::getRows
File
- modules/
linkedin/ social_content_linkedin.class.inc, line 187 - Social Content Linkedin class.
Class
- SocialContentLinkedin
- @file Social Content Linkedin class.
Code
public function getRows($last_id = NULL) {
$settings = $this->settings['instance'];
$global_settings = $this->settings['global'];
if (empty($global_settings['access_token'])) {
watchdog('social_content_linkedin', 'Error fetching feed, data: %data', array(
'%data' => "empty access token",
), WATCHDOG_WARNING);
drupal_set_message(t('Error: Access Token is empty.'), 'error');
}
else {
if (!empty($settings['company_id'])) {
// TODO: Job postings and products have a different format.
$params = array(
'format' => 'json',
'oauth2_access_token' => $global_settings['access_token'],
'event-type' => 'status-update',
);
if (!empty($settings['limit'])) {
$params['count'] = $settings['limit'];
}
$url = $global_settings['api_url'] . '/' . $global_settings['api_version'] . '/companies/' . $settings['company_id'] . '/updates';
$result = $this
->httpRequest(url($url, array(
'query' => $params,
'external' => TRUE,
)));
if ($result->code == 200) {
$posts = json_decode($result->data);
if (isset($posts->values)) {
return $posts->values;
}
}
else {
watchdog('social_content_linkedin', 'Error fetching feed, data: %data', array(
'%data' => $result->data,
), WATCHDOG_WARNING);
drupal_set_message(t('Error: @error', array(
'@error' => $result->data,
)), 'error');
}
}
}
return array();
}