Este sitio web utiliza cookies para realizar análisis y mediciones de tus visitas. [ Acepto ] [ Más información aquí ].

How to Get Likes from a Facebook Page in PHP

To get the number of all likes received by a Facebook Page, use the following PHP code. Replace "Google" with the name of the page you want:

$page = "Google";

$url = "http://graph.facebook.com/".$page;

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$raw = curl_exec($ch);

curl_close($ch);

$data = json_decode($raw);

$likes = intval($data->likes);

echo $likes;

If the page has numbers in it, use only the numbers to perform the query. For example, for http://es-es.facebook.com/pages/Podemos/269212336568846, use:

$page = "269212336568846";

Añadir comentario