开发者

how to send post to facebook using fbconnect in iphone?

FBSession.m

- (BOOL)resume {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    FBUID uid = [[defaults objectForKey:@"FBUserId"] longLongValue];
    if (uid) {
        NSDate* expirationDate = [defaults objectForKey:@"FBSessionExpires"];
        if (!expirationDate || [expirationDate timeIntervalSinceNow] > 0) {
            _uid = uid;
            _sessionKey = [[defaults stringForKey:@"FBSessionKey"] copy];
            _sessionSecret = [[defaults stringForKey:@"FBSessionSecret"] copy];
            _expirationDate = [expirationDate retain];

            for (id<FBSessionD开发者_Go百科elegate> delegate in _delegates) {
                [delegate session:self didLogin:_uid]; // this is the line where i m getting stuck while looping break
            }

            return YES;
        }
    }

    return NO;
}

#pragma mark Facebook

- (void)session:(FBSession *)session didLogin:(FBUID)uid{
    NSLog(@"Facebook Logged in");

    FBStreamDialog *dialog = [[[FBStreamDialog alloc] initWithSession:fbsession] autorelease];
    dialog.delegate=self;

    Note *note;
    NSString *str = [note noteTitle];

    dialog.attachment = [NSString stringWithFormat: @"{\"name\" : \"Death Diary Bucket List Item\",\"href\" : \"http://ifidieapp.com\",\"caption\" : \"{*actor*} added a Bucket List Item\",\"description\" : \"%@ \",\"media\": [{\"type\": \"image\",\"src\":  \"http://deathdiaryapp.com/wp-content/uploads/2010/01/facebook-big-icon.jpg\",\"href\": \"http://ifidieapp.com\"}]}",str];

    }

    dialog.userMessagePrompt = @"Enter anything about the item here:";
    [dialog show];
}

What could be wrong?


not sure why you should have a array of delegate...

if stuck, try the old API:

facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID"];
[facebook dialog:@"stream.publish" andParams:fbArguments andDelegate:self];

easier, faster (for prototyping or light needs. if you want a specific answer to your issue, please provide more details (where do you initialize your fb object, where do you call FBSession from).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜