2011-07-27 74 views
0

我正试图在Facebook上创建应用程序。用户应该从该应用程序上传照片或评论到应用程序的相册。 我做了评论部分,所以用户可以从应用程序发表评论到应用程序的墙上。PHP Facebook图形API:如何在Facebook的自定义应用程序相册上发布照片

但我无法将照片发布到应用程序相册。当我上传任何图片时,它会转到用户墙上。

下面的代码是即时通讯使用的。

$fb = new Facebook(array(
'appId' => '2420527xxxxxxx', 
'secret' => 'a6b14d618xxxxxxxxxxxxxxxxxxx' 
)); 

$graph_url= "https://graph.facebook.com/".$fb->getAppId()."/photos?access_token=".$fb->getAccessToken();   

echo " 
<form enctype="multipart/form-data" action="'.$graph_url.'" method="post"> 
    <input name="source" type="file" /><br/> 
    <input name="message" type="text" value="" /><br/> 
    <input type="submit" value="Upload"/> 
</form> 
";     

有没有人在这里做过之前......?任何帮助将不胜感激

回答

0

这张照片不会在他们的墙上,它实际上是要在他们的个人资料中为您的应用程序创建一个新的专辑。看看他们的相册,你应该看到它。当新照片上传到相册时,Facebook会在屏幕上张贴一些未指定的魔术。

如果您希望照片转到特定相册,那么您需要指定照片应该转到的相册ID。

// first get your album id, let's assume you need to create it 
// create this before hand and you can just reference the id 
$attachment = array('access_token'=> ACCESS_TOKEN, 'name'=>$ablum_name); 
try{ 
    $album_resp = $facebook->api("/{$this->page_id}/albums", 'POST', $attachment); 
}catch(Exception $e){ 
    throw new Exception("Failed to create album: ". $e->getMessage()); 
} 
$album_id = $album_resp['id']; 

$graph_url= "https://graph.facebook.com/". $album_id ."/photos?access_token=".$fb->getAccessToken(); 

// continue with your posting... 
+0

嘿感谢您的回复,我可以在用户的​​个人资料上张贴与该应用程序的名称相册。我想要的是专辑/照片,而不是进入用户个人资料,它应该在应用程序的照片部分进行...因此,该应用程序的所有FANS都可以看到它...您是否遵循我想要的内容做..? – ujwaltrivedi

+0

是的,我明白你在说什么。您是否尝试过使用您为应用创建的相册的ID? – covati

+0

尝试过,但没有工作... – ujwaltrivedi

相关问题