0

我照片上传到Facebook页面相册使用以下网址Facebook的照片上传到网页相册

<form id ="uploadForm" method="post" enctype="multipart/form-data"> 
     <h4>UPLOAD PHOTO</h4> 

     <fieldset> 
     <input id="name" type="text" /> 
     </fieldset> 
     <fieldset> 
     <textarea id="photoDtls"></textarea> 
     </fieldset> 
     <fieldset> 
     <input name ="source" type="file" /> 
     </fieldset> 
     <input type="submit"> 
     </form> 

而且我用下面的JavaScript SDK代码

FB.getLoginStatus(function(response) { 
      if (response.status === 'connected') { 
       accessToken = response.authResponse.accessToken; 
        $('#uploadForm').attr('action','https://graph.facebook.com/photos/*page_album_id*?access_token='+accessToken); 
       }); 
      } else if (response.status === 'not_authorized') { 
       alert('not autherized'); 
       FB.login(function(response){ 
       alert('Permission granted');     
       },{scope: 'email,user_birthday,publish_stream,photo_upload'}); 
      } else { 
       alert('not logged in'); 
      // the user isn't logged in to Facebook. 
      } 
     }); 

我得到的回应时,我上传该照片,但我没有看到照片上传到我的相册。有没有办法通过以下ID或ID后检查照片?这里可能出了什么问题?

{ 

    "id": "xxxxxxxxxxxxxxxxxxxxx", 
    "post_id": "xxxxxxxx_xxxxxxxxxxxxx" 

} 
+0

当您访问Facebook上的id或post_id时,您会看到什么?像www.facebook.com/ - 有你的照片吗? – Jurik

+0

https://graph.facebook.com/_post-id_给我'{ “错误”:{ “消息”: “不支持GET请求。” “类型”: “GraphMethodException”, “代码”: 100 } }' –

+0

你使用这个例子:https://developers.facebook.com/blog/post/498/?我有一个类似的问题,但它与PHP - 因为我需要将图片保存在服务器上,以及:http://stackoverflow.com/questions/7340949/is-it-possible-to-upload-a-photo-没有发布 - 它有图像'图像'而不是'源'的名字。 – Jurik

回答

1

要将照片上传到fanpage,您需要使用fanpage令牌而不是用户令牌。

要获得此令牌,您需要授予manage_pages权限 - 没有别的。然后,您将获得fanpage标记并将其保存在服务器上的某个位置,因为这需要将照片上传到粉丝页面。

这意味着你不能用javascript来做到这一点。因为那么每个人都会看到你的fanpage访问令牌。

因此,您必须将照片发送到您的网络服务器,然后将其上传到您的fanpage专辑。

+0

你是对的。但是当我使用应用程序访问令牌作为access_token时,我得到一个错误消息'用户访问令牌需要请求这个资源'我已经要求'scope:'email,user_birthday,publish_stream,photo_upload'}'与应用连接时 –

+1

我更新了答案。后来当我在家时,我也可以发布一个例子 - 因为我在Facebook上有一个正在运行的应用程序,作为页面标签,它完全符合你的需求。但它破坏atm,因为我改变了我的密码,但没有更新我的访问令牌;)https://www.facebook.com/PowerPhotoUploader/app_300214813374674 – Jurik

+0

http://stackoverflow.com/questions/20490801/how-to -get-photos-uploaded-via-facebook-application你对这个有什么想法吗? manage_pages只允许管理员用户上传到他们的页面 –