【问题标题】:how to send post to facebook using fbconnect in iphone?如何在 iphone 中使用 fbconnect 将帖子发送到 facebook?
【发布时间】:2023-03-31 07:45:01
【问题描述】:

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

可能出了什么问题?

【问题讨论】:

    标签: objective-c cocoa-touch fbconnect


    【解决方案1】:

    不知道为什么你应该有一个委托数组...

    如果卡住了,试试旧的 API:

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

    更简单、更快(用于原型设计或轻型需求。 如果您想具体回答您的问题,请提供更多详细信息(您在哪里初始化您的 fb 对象,您从哪里调用 FBSession)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多