我是Wistia.com的新手,我想知道是否有一种方法可以使用javascript / jquery或php来获得我的视频所拥有的Facebook喜欢的数量?我正在使用Wistia API。
function count_fb_like($yourUrl) {
$json_string = file_get_contents_curl('http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls='.$yourUrl);
$json = json_decode($json_string, true);
return isset($json[0]['total_count'])?intval($json[0]['total_count']):0;
}
function file_get_contents_curl($url){
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT,60);
$cont = curl_exec($ch);
if(curl_error($ch)){
die(curl_error($ch));
}
return $cont;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句