You are here

public function AddThis::getNodeEmailCount in Drupal Most Popular 6

Gets the most emailed nodes from AddThis.com for the given period of time.

Parameters

integer $ts: The timestamp that starts the desired period of time that ends now. We use this to calculate whether we're interested in the last day, week or month. Note that year is not yet supported by AddThis.com.

Return value

array An array of associative arrays, each containing:

  • shares: The number of times the page was shared.
  • url: The URL of the page.

File

modules/mostpopular_addthis/mostpopular_addthis.classes.inc, line 172
Provides a connector to the AddThis.com API.

Class

AddThis
@file Provides a connector to the AddThis.com API.

Code

public function getNodeEmailCount($ts = 0) {
  $params = array(
    'service' => 'email',
  );
  $now = time();
  if (strtotime('-1 day -10 minutes') <= $ts) {
    $params['period'] = 'day';
  }
  elseif (strtotime('-1 week -10 minutes') <= $ts) {
    $params['period'] = 'week';
  }
  elseif (strtotime('-1 month -10 minutes') <= $ts) {
    $params['period'] = 'month';
  }
  else {
    return FALSE;
  }
  return $this
    ->fetchCSV('content', $params);
}