gpt4 book ai didi

dialog - Feed 对话框无法在 iOS SDK 3.0 beta 上运行(API 错误代码 110)

转载 作者:行者123 更新时间:2023-12-02 11:27:08 25 4
gpt4 key购买 nike

我正在更新我的应用程序以使用新的 iOS 版 Facebook SDK (3.0)。但是,我在尝试使用提要对话框时遇到了问题。我关注了instructions在 Facebook 的开发者网站上了解如何通过新 SDK 使用提要对话框,但当我显示该对话框时收到此错误:

API Error Code: 110
API Error Description: Invalid user id
Error Message: Missing user cookie (to validate session user)

这是我的代码:

Facebook *facebook = [[Facebook alloc] initWithAppId:FBSession.activeSession.appID andDelegate:nil];

facebook.accessToken = FBSession.activeSession.accessToken;
facebook.expirationDate = FBSession.activeSession.expirationDate;

NSMutableDictionary *feedParams = [[NSMutableDictionary alloc] init];

[feedParams setObject:self.video.alternateLink.href
forKey:@"link"];
// link title = video title
[feedParams setObject:self.video.title.stringValue
forKey:@"name"];
// link picture = video thumbnail
[feedParams setObject:self.video.mediaGroup.highQualityThumbnail.URLString
forKey:@"picture"];

NSDictionary *privacyDict = [NSDictionary dictionaryWithObjectsAndKeys:@"CUSTOM", @"value", @"SELF", @"friends", nil];
SBJSON *jsonWriter = [[SBJSON alloc] init];

[feedParams setObject:[jsonWriter stringWithObject:privacyDict error:NULL]
forKey:@"privacy"];

[jsonWriter release];

[facebook dialog:@"feed"
andParams:feedParams
andDelegate:self];

[feedParams release];

self.facebook = facebook;
[facebook release];

这似乎是一个身份验证问题,但我正在将有效的访问 token 传递给 Facebook 对象,所以我不确定问题是什么。如果有人能帮助我,那就太好了。谢谢。

最佳答案

在与旧版 Facebook 类集成时,您可以使用 FBSession.activeSession,如您所示。当您使用 activeSession 而不是直接实例化 session 对象时,一个可能的问题是它可能未打开。下面是一个简单的示例,显示了将 Facebook 类与事件 session 集成的表单:

if (FBSession.activeSession.isOpen) {
// Create a Facebook instance
Facebook *facebook = [[Facebook alloc] initWithAppId:FBSession.activeSession.appID
andDelegate:nil]; // commonly self

// Set the session information for the Facebook instance
facebook.accessToken = FBSession.activeSession.accessToken;
facebook.expirationDate = FBSession.activeSession.expirationDate;

// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"I'm using the the Facebook SDK for iOS", @"name",
@"Facebook for iOS", @"caption",
@"Check out the Facebook SDK for iOS!", @"description",
@"https://developers.facebook.com/ios", @"link",
@"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png", @"picture",
nil];

// Invoke the dialog
[facebook dialog:@"feed" andParams:params andDelegate:nil];

[facebook release];
}

如果事件 session 未打开,那么您将遇到与您所看到的类似的失败。在您的逻辑中较早的地方进行如下调用可以解决此问题:

[FBSession openActiveSessionWithAllowLoginUI:YES];

希望这有帮助!

关于dialog - Feed 对话框无法在 iOS SDK 3.0 beta 上运行(API 错误代码 110),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11729800/

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