0

有谁知道如何获取与应用 id 关联的用户的活动提要?

我可以使用此代码获取与应用 ID 关联的用户列表

<?php 
    require "facebook.php";
    $facebook = new Facebook(array(
        'appId'  => '',
        'secret' => '',
    )); 
    $user = $facebook->getUser();
    if ($user) {
      try {
            $result = $facebook->api(array(
            "method"    => "fql.query",
            "query"     => "SELECT uid, name, pic_square, activities FROM user
            WHERE uid IN (SELECT uid1 FROM friend WHERE uid2 = me()) and  is_app_user"
        ));
    echo "<pre>"; 
    print_r($result);
?>

输出

Array
(
    [0] => Array
        (
            [uid] => 14529121124
            [name] => Saurabh
            [pic_square] => http://profile.ak.fbcdn.net/hprofile-ak-ash4/187195_1452918224_6692287_q.jpg
            [activities] => 
        )

    [1] => Array
        (
            [uid] => 100000565666371
            [name] => Abhijeet
            [pic_square] => http://profile.ak.fbcdn.net/hprofile-ak-prn1/157718_100000289210371_1409561577_q.jpg
            [activities] => 
        )

)


现在我只想获取与此(54975723243503)app_id关联的这两个用户(用户 ID:14529121124、100000565666371 )的活动提要。

4

2 回答 2

2

使用图形 API:https ://developers.facebook.com/docs/reference/api/user/

在该页面中搜索“提要”

于 2013-01-15T13:17:32.890 回答
1

您需要查询 FQL表或 Graph API feed 对象:

由于您使用的是 FQL,我将举一个使用 FQL 的示例。我做了一些快速测试,该stream表不允许您使用IN关键字从多个源中选择流,因此您需要进行两次单独的调用,第一次获取user_ids,第二次获取流。

尝试这个:

$queries = array();
$i = 0;
foreach ($result as $item) {
   $queries['user_stream'.$i] =>
     "SELECT source_id, created_time, message, attachment FROM stream 
        WHERE source_id = " . $item['uid'];
   $i++;
}

$result2 = $facebook->api(array(
        "method"    => "fql.multiquery",
        "queries"     => json_encode($queries)
         ));
于 2013-01-15T14:23:25.633 回答