Facebook职位的许可是“只有我”使用FBWebDialogs [英] The permission of Facebook post is "Only me" using FBWebDialogs
问题描述
我想将文字和从iOS应用程序链接到用户时间轴。我复制并粘贴FBWebDialogs的例子。
问题1:
该帖子显示在我的时间轴上,但权限是只有我,而不是朋友或公开。
问题2:
结果对象(FBWebDialogResult)为零。日志出现在我的控制台中.NSLog(@用户取消了故事发布);
问题3:
预览框的权限是只有我即使我设置为public
我的Facebook页面的附加设置:
这是我的代码:
[FBWebDialogs presentFeedDialogModallyWithSession:nil
参数:params
处理程序:
^(FBWebDialogResult结果,NSURL * resultURL,NSError *错误){
如果(错误){
//启动对话框或发布故事时出错。
NSLog(@发布故事错误);
} else {
if(result == FBWebDialogResultDialogNotCompleted){
//用户点击x图标
NSLog(@用户已取消故事发布);
} else {
//处理发布Feed回调
NSDictionary * urlParams = [self parseURLParams:[resultURL query]];
if(![urlParams valueForKey:@post_id]){
NSLog(@用户取消故事发布);
} else {
NSString * msg = [NSString stringWithFormat:
@发布的故事,id:%@,
[urlParams valueForKey:@post_id]]
[[[UIAlertView alloc] initWithTitle:@Result
message:msg
委托:nil
cancelButtonTitle:@OK!
otherButtonTitles:nil]
show];
}
}
}
}];
我的应用的设置页面默认是只有我。我不希望我的所有用户在此处更改此设置。
OMG。我一整天都在努力,但没有进步。我问问题后,我找到了解决方案。
问题是我复制了不适当的示例代码。改为[FBSession openActiveSessionWithPublishPermissions]并解决问题。
这是我使用的登录代码。我的帖子现在可以公开。
- (void)buttonRequestClickHandler:(id)sender {
// FBSample logic
//检查我们是否已经打开了一个会话。
if(FBSession.activeSession.isOpen){
// login与发送按钮集成 - 所以如果打开,我们发送
// [self sendRequests];
NSLog(@登录Facebook);
} else {
NSArray * permission = [NSArray arrayWithObjects:@publish_actions,nil];
[FBSession openActiveSessionWithPublishPermissions:permission defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession * session,
FBSessionState status,
NSError * error){
//如果登录失败,原因,我们警告
如果(错误){
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@错误
消息:error.localizedDescription
委托:nil
cancelButtonTitle:@OK
otherButtonTitles:无];
[alert show];
//如果否则我们检查会话是否打开,另一个
//对FB_ISSESSIONOPENWITHSTATE帮助宏将是检查会话对象的isOpen
//属性;宏,但是,更多
//详细的状态检查FBSession对象
} else if(FB_ISSESSIONOPENWITHSTATE(status)){
//发送我们的请求,如果我们成功登录
NSLog(@登录Facebook); }
}];
}
I want to post text and link from iOS app to user timeline. I copy and paste FBWebDialogs example.
Problem 1: The post appear in my timeline but the permission is "Only me", not friend or public.
Problem 2: The result object (FBWebDialogResult) is nil. Log appear in my console.NSLog(@"User canceled story publishing.");
Problem 3: The permission of preview box is "only me" even I set it to public
Attached setting of my Facebook page:
Here is my code:
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or publishing a story.
NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(@"User canceled story publishing.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
NSLog(@"User canceled story publishing.");
} else {
NSString *msg = [NSString stringWithFormat:
@"Posted story, id: %@",
[urlParams valueForKey:@"post_id"]];
[[[UIAlertView alloc] initWithTitle:@"Result"
message:msg
delegate:nil
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}
}
}
}];
The setting page of my app is "only me" by default. I don't expect all my users change this setting here.
OMG. I stuggled for whole day but no progress. I found solution as soon as I ask question.
The problem is I copied inappropriate sample code. Ichanged to [FBSession openActiveSessionWithPublishPermissions] and problem solved.
Here is the login code I used. My post can be public now.
- (void)buttonRequestClickHandler:(id)sender {
// FBSample logic
// Check to see whether we have already opened a session.
if (FBSession.activeSession.isOpen) {
// login is integrated with the send button -- so if open, we send
// [self sendRequests];
NSLog(@"Login in facebook");
} else {
NSArray *permission = [NSArray arrayWithObjects:@"publish_actions", nil];
[FBSession openActiveSessionWithPublishPermissions:permission defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// if login fails for any reason, we alert
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
// if otherwise we check to see if the session is open, an alternative to
// to the FB_ISSESSIONOPENWITHSTATE helper-macro would be to check the isOpen
// property of the session object; the macros are useful, however, for more
// detailed state checking for FBSession objects
} else if (FB_ISSESSIONOPENWITHSTATE(status)) {
// send our requests if we successfully logged in
NSLog(@"Login in facebook"); }
}];
}
这篇关于Facebook职位的许可是“只有我”使用FBWebDialogs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!