How to get facebook recommendations in php

Can anyone help how to get the facebook counter recommended in php.

I am looking for a facebook api, but I found something.

Thanks in advance.

+3
source share
3 answers

Recommendation is how. You can see it in a link to a button like:

action- a verb to display on the button. Options: how, recommend

To get the counts for the url (here http://stackoverflow.com), you can make an FQL call:

 SELECT url, share_count, like_count, comment_count, total_count
 FROM link_stat WHERE url="http://stackoverflow.com"

Direct call

$fql = 'SELECT url, share_count, like_count, comment_count, total_count
        FROM link_stat WHERE url="http://stackoverflow.com"';
$json = file_get_contents('https://api.facebook.com/method/fql.query?format=json&query=' . urlencode($fql));

And $jsonwill contain:

[
    {
        "url"           : "http://stackoverflow.com",
        "share_count"   : 1353,
        "like_count"    : 332,
        "comment_count" : 538,
        "total_count"   : 2223
    }
]

You have here:

  • share_count: stock count for URL
  • like_count: number of likes (= recommendations)
  • comment_count: The number of comments on Facebook below the shares of this link.
  • total_count: abstract sum 3 is considered

You can read json in PHP with json_decode:

$data = json_decode($json);
echo  $data[0]->like_count;

PHP PHP SDK

EDIT: , , , PHP PHP SDK (. github), FQL: Facebook ( ) API (. Facebook). , : SDK .

require "facebook.php";
$facebook = new Facebook(array(
    'appId'  => YOUR_APP_ID,
    'secret' => YOUR_APP_SECRET,
));

$fql = 'SELECT url, share_count, like_count, comment_count, click_count, total_count 
        FROM link_stat WHERE url="http://stackoverflow.com"';

$result = $facebook->api(array(
    'method' => 'fql.query',
    'query' => $fql,
));

$result , ( like_count) :

Array (
    [0] => Array (
        [url] => http://stackoverflow.com
        [share_count] => 1356
        [like_count] => 332
        [comment_count] => 538
        [click_count] => 91
        [total_count] => 2226
    )
)
+6

FQL.

<?php
require_once('../library/Facebook.php');
$facebook = new Facebook(array(
    'appId'  => '123456789000000',
    'secret' => 'asdf',
    'cookie' => true,
));
$result = $facebook->api(array(
    'method' => 'fql.query',
    'query' => 'select like_count, total_count, share_count, click_count from link_stat where url="http://<url>";'
));
echo $result[0]['total_count'];
?>

. http://www.cwd.at/2011/04/facebook-tipp-anzahl-der-fans-die-eine-fan-page-liken/.

EDIT: . http://facebook.cwd.at/so.php URL, . ( SDK)

+1

To just browse shared resources that you can browse / consume http://graph.facebook.com/http://yourdomain.com

For example: http://graph.facebook.com/http://www.apple.com/ipod

+1
source

All Articles