Aks*_*eri 4 facebook deep-linking facebook-graph-api ios
我使用下面的代码发布到Facebook.它工作得很好但是当我用myapp:// test_page替换MY_URL时//帖子不会出现在Facebook时间线上.
如果我做错了,那么请告诉我如何将我的应用程序深入链接到Facebook应用程序.我搜索了几乎所有的stackoverflow.com页面和其他Facebook开发人员教程,但我无法理解.
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
[params setObject:@"Check out my post in myapp" forKey:@"message"];
[params setObject:MY_URL forKey:@"link"];
[params setObject:MY_IMAGE_URL forKey:@"picture"];
[params setObject:self.strQuestion forKey:@"name"];
[params setObject:@"" forKey:@"caption"];
[params setObject:self.strDescription forKey:@"description"];
[FBRequestConnection startWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST"
 completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
     NSLog(@"FACEBOOK DONE");
 }];
谢谢你回答@Jai Govindani,但它比你的回答简单得多.我从Facebook文档中发现了这一点.
首先,我更改Facebook帐户中的应用程序设置:

我在应用程序的设置中添加了Bundle标识符.并启用Facebook deep linking 
当然,我也需要"App store ID"
用以下方法写下面的方法completionBlock-
- (void)shareOnFacebookWithName:(NSString *)strName withDescription:(NSString *)strDesc withLink:(NSString *)strLink WithPictureLink:(NSString *)strPicLink withCaption:(NSString *)strCaption withCompletionBlock:(shareCompletion)completionBlock
{
    __block NSString *strLinkBlock = strLink;
    [FBSession openActiveSessionWithPublishPermissions: [NSArray arrayWithObjects: @"publish_stream", nil] defaultAudience: FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler: ^(FBSession *session,FBSessionState status,NSError *error)
     {
         if (error)
         {
             completionBlock(NO);
             return;
             NSLog(@"error");
         }
         else
         {
             [FBSession setActiveSession:session];
             NSLog(@"LOGIN SUCCESS");
             // Put together the dialog parameters
             NSArray* actionLinks = [NSArray arrayWithObjects:
                                     [NSDictionary dictionaryWithObjectsAndKeys:
                                      @"Scisser",@"name",
                                      @"http://m.facebook.com/apps/uniquenamespace/",@"link",
                                      nil],
                                     nil];
             NSString *actionLinksStr = [actionLinks JSONRepresentation];
             if (strLink.length == 0)
             {
                 strLinkBlock = @"http://www.scisser.com";
             }
             NSString *strDescription = strDesc;
             if (!strDescription)
             {
                 strDescription = @"";
             }
             NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                            strName, @"name",
                                            strCaption, @"caption",
                                            strDescription, @"description",
                                            strLinkBlock, @"link",
                                            strPicLink, @"picture",
                                            @"foo", @"ref",
                                            actionLinksStr, @"actions",
                                            nil];
             // Make the request
             [FBRequestConnection startWithGraphPath:@"/me/feed"
                                          parameters:params
                                          HTTPMethod:@"POST"
                                   completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                       if (!error)
                                       {
                                           // Link posted successfully to Facebook
                                           [self alertshowWithTitle:@"Congratulations" message:@"Post was successfully shared on your Facebook timeline."];
                                           NSLog(@"%@",[NSString stringWithFormat:@"result: %@", result]);
                                           completionBlock(YES);
                                           return;
                                       }
                                       else
                                       {
                                           // An error occurred, we need to handle the error
                                           // See: https://developers.facebook.com/docs/ios/errors
                                           NSLog(@"%@",[NSString stringWithFormat:@"%@", error.description]);
                                           completionBlock(NO);
                                           return;
                                       }
                                   }];
         }
     }];
}
| 归档时间: | 
 | 
| 查看次数: | 11111 次 | 
| 最近记录: |