iphone FBconnect - 为多个朋友发布流

时间:2011-03-22 13:47:04

标签: iphone facebook fbconnect

目前正在开发iphone应用程序(facebook connect),

是否可以将消息发布到MULTIPLE朋友的墙上?目前,我可以使用“PUBLISH STREAM”在单个朋友的墙上发送消息。

SO使用发布流是否可以一次在多个朋友的墙上发送消息?

1 个答案:

答案 0 :(得分:1)

我猜没有这样的功能。但你可以做到。

检查示例:

这些是添加到类中的Fb委托方法。

- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"received response");
};

获取朋友UID:登录后获取朋友详细信息并将朋友UId存储在数组'uids'中

- (void)request:(FBRequest *)request didLoad:(id)result {   
    if([result isKindOfClass:[NSDictionary class]]) {
        NSLog(@"dictionary");
        result=[result objectForKey:@"data"];
        if ([result isKindOfClass:[NSArray class]]) {   
            for(int i=0;i<[result count];i++){
                NSDictionary *result2=[result objectAtIndex:i];
                NSString *result1=[result2 objectForKey:@"id"];
                NSLog(@"uid:%@",result1);
                [uids addObject:result1];
            }       
        }
    }
}
- (void)request:(FBRequest *)request didLoadRawResponse:(NSData *)data
{
    NSString *dataresponse=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
    NSLog(@"data is :%@",dataresponse);
}

向所有FB好友发帖:

Itterate the post till [uids count];
- (void)conncetToFriends:(id)sender {
    static int ij=0;
    NSMutableDictionary* params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:appId, @"api_key", @"Happy Holi", @"message", @"http://www.holifestival.org/holi-festival.html", @"link", @"http://www.onthegotours.com/blog/wp-content/uploads/2010/08/Holi-Festival.png", @"picture", @"Wanna Kno abt HOLI.. Check this...", @"name", @"Wish u 'n' Ur Family, a Colourful day...", @"description", nil];
    NSLog(@"uid count:%i",[uids count]);
    for(int i=0;i<[uids count];i++) {
        NSString *path=[[NSString alloc]initWithFormat:@"%@/feed",[uids objectAtIndex:i]];
        NSLog(@"i value:%i",ij);
        //[facebook dialog:@"me/feed" andParams:params1 andDelegate:self];
        [facebook requestWithGraphPath:path andParams:params1 andHttpMethod:@"POST" andDelegate:self];
        ij++;
    }
}