开始拉我的头发,无法完成这项工作。
我正在尝试将带有消息的照片发布到 Facebook 页面。
但是无论我做什么,我设置了什么权限,答案总是(#200)用户没有授权应用程序执行此操作。
我正在关注本教程的事件:http ://www.sergiy.ca/post-on-facebook-app-wall-and-fan-page-wall-as-admin/
var image = event.media;
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'camera_photo.png');
f.write(image);
var blob = f.read();
fb.permissions = ['publish_actions', 'publish_stream', 'read_stream','manage_pages']; // Permissions your app needs
fb.reauthorize();
var at = 'pageToken'
var xhrN = Titanium.Network.createHTTPClient();
xhrN.timeout = 1000000;
xhrN.onload = function(){
Ti.API.info(this.responseText);
var thetoken = this.responseText;
Ti.API.info('https://graph.facebook.com/v2.1/' + pageid + '/photos?'+ thetoken);
var xhr = Ti.Network.createHTTPClient({
onload: function(e) {
alert(e);
Ti.API.info('Photo Saved');
Ti.API.info(e);
}
});
var endPoint = 'https://graph.facebook.com/v2.1/' + pageid + '/photos';
xhr.open('POST',endPoint);
xhr.send({
message: 'This is my message',
picture: event.media
});
var data = {
name : "The Name",
message : 'The Message',
caption : "The caption",
access_tokxen: thetoken
};
/*
fb.requestWithGraphPath('123456789/feed', data, 'POST', function(e) {
if (e.success) {
alert(e.result);
Ti.API.info('App projde');
} else if (e.error) {
alert(e.error);
} else {
alert('Unknown response');
}
});
*/
fb.requestWithGraphPath('123456789/feed', data, 'POST', function(e) {
if (e.success) {
alert(e.result);
Ti.API.info('Wall projde');
} else if (e.error) {
alert(e.error);
} else {
alert('Unknown response');
}
});
// *****
};
xhrN.open('GET','https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=clientid&client_secret=clientsecret');
xhrN.send();