gpt4 book ai didi

ios - Facebook 帖子的权限是 "Only me"使用 FBWebDialogs

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:10:21 24 4
gpt4 key购买 nike

我想将文本和链接从 iOS 应用发布到用户时间轴。我复制并粘贴 FBWebDialogs 示例。

问题 1:该帖子出现在我的时间轴中,但权限是“只有我”,而不是 friend 或公众。

问题 2:结果对象 (FBWebDialogResult) 为 nil。日志出现在我的控制台中。NSLog(@"User canceled story publishing.");

问题 3:预览框的权限是“只有我”,即使我将其设置为公开 enter image description here

我的 Facebook 页面的附加设置: enter image description here

这是我的代码:

[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];
}
}
}
}];

我的应用的设置页面默认是“only me”。我不希望我的所有用户都在此处更改此设置。

最佳答案

我的天哪。我挣扎了一整天,没有任何进展。我一提出问题就找到了解决方案。

问题是我复制了不合适的示例代码。我更改为 [FBSession openActiveSessionWithPublishPermissions] 并解决了问题。

这是我使用的登录代码。我的帖子现在可以公开了。

- (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"); }
}];
}

关于ios - Facebook 帖子的权限是 "Only me"使用 FBWebDialogs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16291837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com