【发布时间】:2013-12-09 17:59:30
【问题描述】:
我使用以下网址将照片上传到 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或post id查看照片?这里可能出了什么问题?
{
"id": "xxxxxxxxxxxxxxxxxxxxx",
"post_id": "xxxxxxxx_xxxxxxxxxxxxx"
}
【问题讨论】:
-
当您访问 facebook 上的 id 或 post_id 时,您会看到什么?比如 www.facebook.com/
- 有你的照片吗? -
graph.facebook.com/_post-id_ 给我
{ "error": { "message": "Unsupported get request.", "type": "GraphMethodException", "code": 100 } } -
你用这个例子吗:developers.facebook.com/blog/post/498?我有一个类似的问题,但用 php 解决了 - 因为我还需要将图片保存在服务器上:stackoverflow.com/questions/7340949/… - 有图像的名称
image而不是source。 -
啊,现在我看到了错误。您想将图片上传到粉丝专页相册,但您使用的是用户访问令牌。那是行不通的。你需要它的页面访问令牌。
-
好,我把它作为答案发布了:)
标签: javascript jquery facebook-graph-api file-upload facebook-javascript-sdk