4

我想获取标记了我的特定朋友照片,以及标记了同一位朋友的照片。我正在使用 fql,类似这样的东西,其中 $_POST[friend_id] 以前是从带有我所有列出的朋友:

$facebook_login = "0";
$user = $facebook->getUser();
$perms = array('scope' => 'email,user_photos,read_mailbox');

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
$facebook_login = "1";
  } catch (FacebookApiException $e) {
    $user = null;
  }

} else {
    die('<script>top.location.href="'.$facebook->getLoginUrl($perms).'";</script>');
}



//friend photos that I'm tagged in
$query = "SELECT id FROM photo WHERE from = $_POST[friend_id] AND tags IN ($user)";
$result = $facebook->api(array(
  'method' => 'fql.query',
  'query' => $query,
));

echo sprintf('<pre>%s</pre>', print_r($result,TRUE));


//my photos with my friend tagged in
$query = "SELECT id FROM photo WHERE from = $user AND tags IN ($_POST[friend_id])";
$result = $facebook->api(array(
  'method' => 'fql.query',
  'query' => $query,
));

echo sprintf('<pre>%s</pre>', print_r($result,TRUE));

我可以这样做吗?

谢谢

4

1 回答 1

2

Try the following queries:

To get your friend's photos where you're tagged:

$friend_id = $_POST['friend_id'];
$query = "SELECT object_id 
          FROM photo 
          WHERE owner=$friend_id AND 
                object_id IN (SELECT object_id FROM photo_tag WHERE subject=me())";

Your photos where your friend is tagged:

$query = "SELECT object_id 
          FROM photo 
          WHERE owner=me() AND 
                object_id IN (SELECT object_id FROM photo_tag WHERE subject=$friend_id)";
于 2013-05-09T00:09:39.060 回答