vendredi 16 août 2013

php twitter followers count and facebook likes count without login



Numbers of likes on facebook page
<?php
         $name = 'PAGE';
         $src = json_decode(file_get_contents('http://graph.facebook.com//'.$name));
    $likes= $src->likes;
echo $likes;
?>

Twitter  code is different i've found this hack on the web (y)
with the code below no need to connect with valid credentials:

$url='http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20from%20html%20where%20url=%22http://twitter.com/XXXXXXX%22%20AND%20xpath=%22//a[@class=\'js-nav\']/strong%22&format=json';
$src = file_get_contents($url);
/*echo($src);*/
$decoded = json_decode($src);
echo ($decoded->query->results->strong[2]);

where XXXXXXX is the account
it works tested on a joomla integration.

Aucun commentaire:

Enregistrer un commentaire