开发者

Facebook Leaderboard App for Fan Page

I’m trying to create a leaderboard for my Facebook Fan Page. Basically what I want is that when a user clicked on the My App Tab in my facebook fan page, they will be shown a list of people that have liked my page and who has invited the most friends to like the page.

You - Invited 20 pe开发者_Go百科ople to this page

Who has broght the most friends to this page.

User A- 200 Friends

User B - 190 Friends

User C - 150 Friends.

Facebook already have that application for its personally use. I want to know if there is a way to develop that for a fan page. Check the facebook leaderboard here. http://www.facebook.com/impact/.

Do you think this code will do the work.

<?php
$auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
            . $app_id . "&redirect_uri=" . urlencode($canvas_page);

$signed_request = $_REQUEST["signed_request"];

list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

     $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

     if (empty($data["user_id"])) {
            echo("<script> top.location.href='" . $auth_url . "'</script>");
     } else {
    $user = $facebook->getUser(); 
    $me = $facebook->api('/me'); 
    $myFriends = $facebook->api('/me/friends');  

    $friends = $facebook->api(array(  
        'method' => 'fql.query',
        'query' => 'select uid from page_fan where uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND page_id ="232101106816088"'  
    ));  
   print_r($friends);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜