你如何在你的网站上显示Facebook好友数量?

时间:2015-02-19 19:36:55

标签: facebook facebook-graph-api facebook-fql

我只想在WordPress博客中显示用户拥有的朋友数量。

我有这个FQL代码:

function fb_count(){
     $fb_id = '00000000'; //Facebook id, which I don't want to put here. 
     $count = get_transient('fb5_count');
     if ($count !== false) return (int)$count[1];
     $count = 0;
     $data = wp_remote_get('https://graph.facebook.com/fql?q=SELECT+friend_count+FROM+user+WHERE+uid='.$fb_id.'');
     if (is_wp_error($data)) {
        return 'Error!!';
    }else{
        preg_match('/(\d+)/', $data[body], $count);
    }
    set_transient('fb5_count', $count, 60*60*24); // 24 hour cache
    return (int)$count[1];
}

现在已经弃用了FQL,如何在没有令牌的情况下获得朋友计数?或者我如何获得这样的非app应用程序的令牌?

0 个答案:

没有答案