1

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.

1 Answers1

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;
    }
HDT
  • 2,017
  • 20
  • 32
  • it gives me Fatal error: Using $this when not in object context in C:\wamp\www\mySite\video.php on line 14. Line 14 in my code is curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); – Eddy Kastle Aug 27 '14 at 06:33
  • curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); fix by curl_setopt($ch, CURLOPT_TIMEOUT,60); i just updated my answer. – HDT Aug 27 '14 at 06:36