调用图 api Facebook ios 时 facebookErrDomain 错误 10000
我在图形 api 上苦苦挣扎了几天,但似乎无法再进一步了。
在我的 appdelegate 中,我将以下代码放置在 didFinishLaunching 中
facebook = [[Facebook alloc] initWithAppId:@"cut-app-id-out"];
NSArray* permissions = [[NSArray arrayWithObjects:
@"email", @"user_location", @"user_events", @"user_checkins", @"read_stream", nil] retain];
[facebook authorize:permissions delegate:self];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"test message from stackoverflow", @"message",
nil];
[facebook requestWithGraphPath:@"/me/feed" andParams:params andDelegate:self];
,如您所见,我正在尝试获取用户提要。我使用以下代码将数据放入正确的字典中。
- (void)request:(FBRequest*)request didLoad:(id)result
{
if ([result isKindOfClass:[NSDictionary class]]) {
NSLog(@"count : %d ", [result count]);
NSArray* resultArray = [result allObjects];
NSLog(@"count : %d ", [result count]);
result = [resultArray objectAtIndex:0];
NSLog(@"count : %d ", [result count]);
result = [result objectAtIndex:0];
}
}
但是 didFailWithError: 函数给了我以下错误: 操作无法完成。 (facebookErrDomain 错误 10000。)
我已将 FBRequestDelegate 放入我的接口文件中,如下所示:
@interface TabbedCalculationAppDelegate : NSObject
<FBRequestDelegate>{
有什么我遗漏的吗?
I'm struggling with the graph api for a few days now and I can't seem to get any further.
In my appdelegate i've placed the following code within the didFinishLaunching
facebook = [[Facebook alloc] initWithAppId:@"cut-app-id-out"];
NSArray* permissions = [[NSArray arrayWithObjects:
@"email", @"user_location", @"user_events", @"user_checkins", @"read_stream", nil] retain];
[facebook authorize:permissions delegate:self];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"test message from stackoverflow", @"message",
nil];
[facebook requestWithGraphPath:@"/me/feed" andParams:params andDelegate:self];
as you can see i'm trying to get the users feed out. I use the following code to place the data into a proper dictionary.
- (void)request:(FBRequest*)request didLoad:(id)result
{
if ([result isKindOfClass:[NSDictionary class]]) {
NSLog(@"count : %d ", [result count]);
NSArray* resultArray = [result allObjects];
NSLog(@"count : %d ", [result count]);
result = [resultArray objectAtIndex:0];
NSLog(@"count : %d ", [result count]);
result = [result objectAtIndex:0];
}
}
But the didFailWithError: function gives me the following error:
The operation couldn’t be completed. (facebookErrDomain error 10000.)
I've place the FBRequestDelegate in my interface file as following:
@interface TabbedCalculationAppDelegate : NSObject
<FBRequestDelegate>{
Is there something what i'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理 Facebook 响应还需要做很多工作,尤其是在授权之后。您将无法在
authorize
方法之后立即调用 Facebook API。请参阅他们的示例代码它展示了如何响应您需要执行的各种事件,最重要的是fbDidLogin
和fbDidNotLogin
事件。只有成功登录后,您才能访问 Graph API。此外,您似乎正在尝试使用 Graph API 发布消息。不幸的是,这不是这样做的方法,像
[facebook requestWithGraphPath:@"me/feed" andDelegate:self]; 这样的调用仅用于只读用途。再次,查看上面的链接,了解如何使用
publish_stream
权限的示例(他们的代码有一个publishStream
示例方法)。There's a lot more needed to handle Facebook responses, especially after authorization. You're not going to be able to make calls against the Facebook API immediately after the
authorize
method. Please see their sample code which shows how to respond to the various events which you will need to do, most importantly thefbDidLogin
andfbDidNotLogin
ones. Only once you have a successful login should you access the Graph API.In addition, it looks like you're trying to post a message with the Graph API. Unfortunately that's not the way to do it and a call like
[facebook requestWithGraphPath:@"me/feed" andDelegate:self];
is meant for read-only use. Again, look at the above link for an example of how to use thepublish_stream
permission (their code has apublishStream
example method).