0

我有一个名为FBSession. 我知道会话已打开,但我如何发送图形请求以创建事件,然后邀请用户参加该事件?我知道用户的 Facebook ID,因为我设法从本地地址簿属性中提取了它们。

    if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
        // even though we had a cached token, we need to login to make the session usable
        [appDelegate.session openWithCompletionHandler:^(FBSession *session,
                                                         FBSessionState status,
                                                         NSError *error) {

        switch (status) {
            case FBSessionStateOpen:
            {

            /* What do I do here to create the event and invite IDs x, y and z where z, y and z are long long Facebook Ids */

            NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                                           @"venue name",@"name",
                                                           @"2012-01-13T17:00:00+0000",@"start_time",
                                                           @"2012-01-16T01:30:00+0000",@"end_time",@"location",@"location name ch",@"1234567890",@"id", nil];
            FBRequest *facebook = [[FBRequest alloc] initWithSession:appDelegate.session graphPath:@"me/events" parameters:params HTTPMethod:@"POST"];

这些是否正确,我需要运行哪些委托方法来检查它在 appDelegate 中是否正常工作?

4

1 回答 1

0

好的,这看起来很酷。

FBRequest *eventPostOK = [FBRequest requestWithGraphPath:@"me/permissions" parameters:Nil HTTPMethod:GET];
[eventPostOK startWithCompletionHandler: ^(FBRequestConnection *connection,
                                           NSDictionary* result,
                                           NSError *error) {
    BOOL canDoIt = FALSE;
    if (!error)
    {
        FBGraphObject *data = [result objectForKey:@"data"];
        for(NSDictionary<FBGraphObject> *aKey in data) {
            canDoIt = [[aKey objectForKey:@"create_event"] boolValue];
        }
    }

    if (canDoIt) { ... DO STUFF .... }

];
于 2013-04-20T07:38:02.807 回答