我想获得我标记的特定朋友照片,以及我的照片,这个朋友被标记在哪里.我正在使用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));
我可以这样做吗?
谢谢
最佳答案 请尝试以下查询:
要将您朋友的照片放到您标记的位置:
$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())";
您朋友被贴上标签的照片:
$query = "SELECT object_id
FROM photo
WHERE owner=me() AND
object_id IN (SELECT object_id FROM photo_tag WHERE subject=$friend_id)";