Question

I'm trying to write a simple app for my website and struggling with 1 point.

A Facebook Page has;

$pageID = 'dorimedia';

What does a website have that is equal? I want to get the value to show how many times an external website has been 'liked'.

Was it helpful?

Solution

Nothing. You could use the domain name, or domain name + path as in full route, but no short ID per se.

If you need something shorter, and not necessarily readable by you, you could hash it or apply some encrypting algorithm to the full url to get a shorter id, try looking into the md5,sha1 or hash methods (assuming your using php)

UPDATE If what you need is how many facebook like's a website has, there is an API for this directly from google that goes like this:

http://api.facebook.com/restserver.php?method=links.getStats&urls=www.google.com

Which results in an xml response that includes, comments, likes and other interesting information. Google for instance has the following response:

<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
     <link_stat>
        <url>www.google.com</url>
        <normalized_url>http://www.google.com/</normalized_url>
        <share_count>2095550</share_count>
        <like_count>795778</like_count>
        <comment_count>705595</comment_count>
        <total_count>3596923</total_count>
        <click_count>265614</click_count>
        <comments_fbid>381702034999</comments_fbid>
        <commentsbox_count>307</commentsbox_count>
    </link_stat>
</links_getStats_response>

Then its a matter of extracting the information from that XML, easily enough like this:

$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url);
$xml = simplexml_load_string($xml);
$shares =  $xml->link_stat->share_count;
$likes =  $xml->link_stat->like_count;
$comments = $xml->link_stat->comment_count;
$total = $xml->link_stat->total_count;
$max = max($shares,$likes,$comments);

Click here for the Source

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top