4
我想要獲取特定朋友的照片,我被加了標籤,並且我的照片也是這個朋友被標記的地方。我使用fql,這樣的地方, $ _POST [friend_id]先前是通過列出所有朋友的表單傳遞的:Facebook api PHP獲取朋友照片我標記的地方
$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));
我可以這樣做嗎?
感謝