Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
730 views
in Technique[技术] by (71.8m points)

iphone - facebookErrDomain error 10000 when calling graph api Facebook ios

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 the fbDidLogin and fbDidNotLogin 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 the publish_stream permission (their code has a publishStream example method).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...