如何让Wistia视频facebook像计数一样

时间:2014-08-27 03:43:35

标签: javascript php jquery video wistia

我是Wistia.com的新手,我想知道是否有办法通过javascript / jquery或php获取我的视频所拥有的facebook数量?我正在使用Wistia API。

1 个答案:

答案 0 :(得分:2)

 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;
    }