开发者

iphone FBconnect - publish stream for multiple friend's

开发者 https://www.devze.com 2023-02-19 11:45 出处:网络
currently i m working on iphone application(facebook connect), Is it possible to post the messages to MULTIPLE friends walls?Currently i am able to send message on single friend wall using \"PUBLISH

currently i m working on iphone application(facebook connect),

Is it possible to post the messages to MULTIPLE friends walls? Currently i am able to send message on single friend wall using "PUBLISH STREAM".

SO Using publish stream is it possible to send message on mult开发者_运维百科iple friend's wall at a time ??


There is no such functionality I guess. But you can do it.

Check the example:

These are Fb delegate methods add to the class.

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

Getting friends UIDs: after logged in get the friends details and store the friends UIds in an array '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);
}

Posting To All FB Friends:

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++;
    }
}
0

精彩评论

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

关注公众号