Facebook Photo Upload to a Page Album

时间:2013-12-09 08:46:35

标签: javascript jquery facebook-graph-api file-upload facebook-javascript-sdk

我使用以下网址将照片上传到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"

}

1 个答案:

答案 0 :(得分:1)

要将照片上传到粉丝专页,您需要使用粉丝页面令牌,而不是用户令牌。

要获得此令牌,您需要授予manage_pages权限 - 不需要其他任何内容。然后你会获得粉丝页面令牌并将其保存在服务器上的某个位置,因为这样你就需要将照片上传到你的粉丝页面。

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

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

相关问题