javascriptphpjqueryvideowistia

How to get Wistia video facebook like count


I'm new to Wistia.com and I was wondering if there was a way to get the number of facebook likes my video has with javascript/jquery or php? I am using the Wistia API.


Solution

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