2011-02-10 44 views
3

如何使用php添加標籤到Facebook照片?facebook photos_addTag方法不起作用

我有此代碼,其中$pid是照片的ID,$userId是我的Facebook ID。

確保我以前>

$facebook = new Facebook($appapikey, $appsecret); 
$user_id = $facebook->require_login(); 
$test = $facebook->api_client->photos_addTag ($pid,$user_id, "text", 50.0, 50.0, '', $user_id); 

$test返回1

,但照片不標記

能有人給我寫什麼我做錯了使用它?

+3

我知道,您使用的是舊的SDK,但如何使用新的PHP-SDK **和**新的圖形API,只是使用舊的其餘`photos.addTag`裏面怎麼新的SDK。 – ifaour 2011-02-10 17:38:13

回答

0
// tag photo parameter 
    $pid = $uid.'_'.$pid; // pid is the photo id, after it uploaded, you need to add the owner id(uid) in front of it, and the real pid is inside the 'link' of the photo's returned json. 
    //tag_uid = $uid; 
    //x = percentage of x position 
    //y = percentage of y position 
    $access_token = $session['access_token']; 

    $tag0 = array('tag_uid'=>$fd0,'x'=>'30.0','y'=>'85.0'); 
    $tag1 = array('tag_uid'=>$fd1,'x'=>'35.0','y'=>'85.0'); 
    $tag2 = array('tag_uid'=>$fd2,'x'=>'40.0','y'=>'85.0'); 
    $tag3 = array('tag_uid'=>$fd3,'x'=>'45.0','y'=>'85.0'); 
    $tag4 = array('tag_uid'=>$fd4,'x'=>'55.0','y'=>'85.0'); 
    $tag5 = array('tag_uid'=>$fd5,'x'=>'60.0','y'=>'85.0'); 
    $tag6 = array('tag_uid'=>$fd6,'x'=>'65.0','y'=>'85.0'); 
    $tag7 = array('tag_uid'=>$fd7,'x'=>'70.0','y'=>'85.0'); 

    $tags = array($tag0,$tag1,$tag2,$tag3,$tag4,$tag5,$tag6,$tag7); 
    $facebook->api(array('method'=>'photos.addTag','pid'=>$pid,'tags'=>json_encode($tags))); 

然而,在新的Facebook的政策,他們似乎不喜歡的應用程序自動標籤的人的照片了。

http://developers.facebook.com/docs/guides/policy/examples_and_explanations/photos/