You are here

public function ShareaholicShareCount::reddit_count_callback in Share Buttons, Related Posts, Content Analytics - Shareaholic 8

Same name and namespace in other branches
  1. 7.3 lib/social-share-counts/share_count.php \ShareaholicShareCount::reddit_count_callback()

Callback function for reddit count API Gets the reddit counts from response

Parameters

Array $response The response from calling the API:

Return value

mixed The counts from the API or false if error

File

lib/social-share-counts/share_count.php, line 208

Class

ShareaholicShareCount
An abstract class Share Counts to be extended

Code

public function reddit_count_callback($response) {
  if ($this
    ->has_http_error($response)) {
    return false;
  }
  $body = json_decode($response['body'], true);

  // special case: do not return false if the ups is not set because the api can return it not set
  return isset($body['data']['children'][0]['data']['ups']) ? intval($body['data']['children'][0]['data']['ups']) : 0;
}