iOS: Post on wall of Selected FB Friends

99封情书 提交于 2020-01-13 04:54:09

问题


Scenario: I would want to share the post to the wall of only selected friends.

Prerequisites followed: Out of the entire list of FB Friends, select only the necessary friends and create an Array

Steps Tried:

Trial 1: Use FBWebDialogs and call method + (void)presentFeedDialogModallyWithSession:(FBSession *)session parameters:(NSDictionary *)parameters handler:(FBWebDialogHandler)handler;

In the Parameters dictionary, set value for "to".

Works perfectly fine when the recipient is only one. Cannot share if the recipient is more than one.

Trial 2: Use FBDialogs and call + (FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params clientState:(NSDictionary *)clientState handler:(FBDialogAppCallCompletionHandler)handler;

In the FBShareDialogParams, set the Array of Friends. works fine. But works only when the Facebook App is installed. Else doesnt work.

...

Can some please help me solve this problem:

  1. Share on wall of multiple Friends.
  2. Should work with or without the Facebook App being installed on phone.

Thanks


回答1:


You must do something like:

FBShareDialogParams *p = [[FBShareDialogParams alloc] init];
p.friends = friendIdsArray;`
p.link = url;

//check if the FB app is installed and can use this method
if ([FBDialogs canPresentShareDialogWithParams:p]) {
    [FBDialogs presentShareDialogWithParams:p 
                                clientState:nil 
                                    handler:^(FBAppCall *call,
                                        NSDictionary *results,
                                               NSError *error) {
            //do some error checking
}
// fallback to what is essentially a webview
else {
    // string of comma separated Facebook Ids
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"1234,5678", @"to", nil];
    NSString *message = @"I love Objective-C";
    [FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
                                                  message:message 
                                                    title:nil 
                                               parameters:params
                                                  handler:^(FBWebDialogResult result,
                                                                    NSURL *resultURL, NSError *error) {
              // do some error checking 
    } 

This is what I use, the only problem I'm finding is that there appears to be some unknown limit to the number of Facebook Ids you can include when sending out a request. It varies and depends on factors I can't find documented. I think FB is trying to keep people from abusing/spamming people, for good reason....



来源:https://stackoverflow.com/questions/19499378/ios-post-on-wall-of-selected-fb-friends

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!