【发布时间】:2015-01-19 10:14:11
【问题描述】:
我正在尝试通过 ipad 应用程序的 Graph api 调用将图像上传到 Facebook 页面上的特定相册。一切正常,来自 Facebook 的响应返回成功,并带有帖子 ID,但我只是看不到页面上上传的图像。我正在使用 Appcelerator Titanium 执行此操作。以下是我的代码:
var fb = require('facebook');
fb.appid = 'MY APP ID';
fb.permissions = ['read_stream'];
function postImageToFb(){
fb.reauthorize(['publish_actions','manage_pages'], 'me', function(e){
if (e.success) {
// If successful, proceed with a publish call
var data = {
source: Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory+'/image.png').read(),
message: 'Hello pic'
}
fb.requestWithGraphPath('<album-id>/photos',data,'POST',function(e){
alert('Post to fb: '+JSON.stringify(e));
if(e.success){
alert('Photo submitted successfully to fb.')
}else{
alert('Failed to upload photo to fb: ')
}
})
} else {
if (e.error) {
alert(e.error);
} else {
alert("Unknown result");
}
}
});
}
$.btn_submit.addEventListener('click',function(e){
if(fb.loggedIn){
postImageToFb();
}else{
fb.authorize();
fb.addEventListener('login',function(e){
if(e.success){
postImageToFb();
}else{
alert('Failed to login fb: ',e);
}
})
}
})
我使用相同的帐户从应用程序创建 Facebook 应用程序、页面和 Facebook 登录名,所以这应该不是问题。可能是什么问题?有人能帮我吗。谢谢。
【问题讨论】:
-
Facebook 应用是否需要上线才能看到通过它上传的内容?
标签: ios facebook facebook-graph-api titanium image-uploading