Syntax
1
2
3
4
5
|
<?php
$page = "koonktechnologies";
$count = fb_fan_count($page);
echo $count;
?>
|
1
2
3
4
5
6
|
function fb_fan_count($facebook_name)
{
$data = json_decode(file_get_contents("https://graph.facebook.com/".$facebook_name));
$likes = $data->likes;
return $likes;
}
|
1
2
3
4
5
|
<?php
$page = "koonktechnologies";
$count = fb_fan_count($page);
echo $count;
?>
|
1
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| function get_url($url){ //user agent is very necessary, otherwise some websites like google.com wont give zipped content $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-Language: en-US,en;q=0.8rn" . "Accept-Encoding: gzip,deflate,sdchrn" . "Accept-Charset:UTF-8,*;q=0.5rn" . "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4rn" ) ); $context = stream_context_create($opts); $content = file_get_contents($url ,false,$context); //If http response header mentions that content is gzipped, then uncompress it foreach($http_response_header as $c => $h) { if(stristr($h, 'content-encoding') and stristr($h, 'gzip')) { //Now lets uncompress the compressed data $content = gzinflate( substr($content,10,-8) ); } } return $content;} |
Hello Friends! I am Ramana a part time blogger from Hyderabad.