public function ShareaholicShareCount::vk_count_callback in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3
Same name and namespace in other branches
- 8 lib/social-share-counts/share_count.php \ShareaholicShareCount::vk_count_callback()
Callback function for vk count API Gets the vk 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 225
Class
- ShareaholicShareCount
- An abstract class Share Counts to be extended
Code
public function vk_count_callback($response) {
if ($this
->has_http_error($response)) {
return false;
}
// This API does not return JSON. Just plain text JS. Example:
// 'VK.Share.count(0, 3779);'
// From documentation, need to just grab the 2nd param: http://vk.com/developers.php?oid=-17680044&p=Share
$matches = array();
preg_match('/^VK\\.Share\\.count\\(\\d, (\\d+)\\);$/i', $response['body'], $matches);
return isset($matches[1]) ? intval($matches[1]) : false;
}