-
-
Save ihorvorotnov/9132596 to your computer and use it in GitHub Desktop.
{"error_code":12,"error_msg":"REST API is deprecated for versions v2.1 and higher (12)","request_args":[{"key":"method","value":"links.getStats"},{"key":"urls","value":"https:\/\/www.youtube.com\/watch?v=-Fnh_-boj1o"},{"key":"format","value":"json"}]}
Facebook now works this way:
http://graph.facebook.com/$URL
Then parse for share->share_count
Twitter doesnt officially work.
One other way is to use 'http://opensharecount.com/count.json?url='.$url
Facebook new share count api: http://graph.facebook.com/?id=your_url
Twitter share count is removed, so no way to get it, don't try it.
Guys need some Advice. Please Check my code if correct... I cant make it work:
/* Get Facebook Data
-------------------------------------------------- */
public function getFacebookData($domain)
{
try
{
$callback_url = "https://graph.facebook.com/v2.1/?";
$data = array(
'id' => "SELECT share_count, like_count, comment_count FROM link_stat WHERE url='$domain'"
);
$curl_response = $this->curl->get($callback_url . http_build_query($data, '', '&'));
if ($curl_response->headers['Status-Code'] == "200") {
$parse_response = json_decode($curl_response, true);
$fb_share_count = $parse_response['data'][0]['share_count'];
$fb_like_count = $parse_response['data'][0]['like_count'];
$fb_comment_count = $parse_response['data'][0]['comment_count'];
} else {
$fb_share_count = 0;
$fb_like_count = 0;
$fb_comment_count = 0;
}
$response = array(
'status' => 'success',
'data' => array(
'fb_share_count' => filter_var($fb_share_count, FILTER_SANITIZE_NUMBER_INT),
'fb_like_count' => filter_var($fb_like_count, FILTER_SANITIZE_NUMBER_INT),
'fb_comment_count' => filter_var($fb_comment_count, FILTER_SANITIZE_NUMBER_INT)
)
);
}
catch (Exception $e)
{
$response = array(
'status' => 'error',
'msg' => $e->getMessage()
);
}
return $response;
}
@ElchinIsmayilov check please my code..still cant get a share from facebook
Hi, does anyone have a solution for the Twitter counter?
ok.ru:
https://connect.ok.ru/dk?st.cmd=extLike&tp=json&ref=https://ya.ru/
• For Twitter, use http://twitcount.com/ or https://jsoon.digitiminimi.com/service_usage.html.
• For Facebook, use https://www.sharedcount.com/
Ah, actually they did ... https://blog.twitter.com/2015/hard-decisions-for-a-sustainable-platform