iOS Facebook SDK - 发布到隐私值设置为 SELF 的 friend 墙未设置

标签 ios facebook-graph-api facebook-ios-sdk facebook-sdk-3.0 fbwebdialogs

我想把我 friend 墙上贴子的隐私设置为SELF。

只有他能看到它,我知道这是可能的,因为有一个属性,但没有记录如何实现这一点。

https://developers.facebook.com/docs/graph-api/reference/post

这是我使用的代码:

NSMutableDictionary *params =
    [NSMutableDictionary dictionaryWithObjectsAndKeys:
     toStr, @"to",
     @"{'value': 'SELF'}", @"privacy",
     @"Facebook SDK for iOS", @"name",
     @"Build great social apps and get more installs.", @"caption",
     @"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", @"description",
     @"https://developers.facebook.com/ios", @"link",
     @"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png", @"picture",
     nil];

    //NSLog(@"params %@", params);
    [FBWebDialogs presentFeedDialogModallyWithSession:nil
                                           parameters:params
                                              handler:
     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             // Error launching the dialog or publishing a story.
             NSLog(@"Error publishing story.");
         } else {
             if (result == FBWebDialogResultDialogNotCompleted) {
                 // User clicked the "x" icon
                 NSLog(@"User canceled story publishing.");
             } else {
                 // Handle the publish feed callback
                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                 if (![urlParams valueForKey:@"post_id"]) {
                     // User clicked the Cancel button
                     NSLog(@"User canceled story publishing.");
                 } else {
                     // User clicked the Share button
                     NSString *msg = [NSString stringWithFormat:
                                      @"Posted story, id: %@",
                                      [urlParams valueForKey:@"post_id"]];
                     NSLog(@"%@", msg);
                     // Show the result in an alert
                     success();
                 }
             }
         }
     }];

但是当我查看 GRAPH api 时,它说:

"privacy": {
          "value": ""
        }, 

最佳答案

试试这个。这可能有帮助。

NSDictionary *privacyDict = [[NSDictionary alloc] initWithObjectsAndKeys:
                   @"SELF",@"value",
                   nil];
SBJSON *jsonWriter = [[SBJSON alloc] init];
NSString *privacyJSONStr = [jsonWriter stringWithObject:privacyDict];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                   @"my message", @"message",
                   privacyJSONStr, @"privacy",
                   nil];

根据自己的用途设置dictionary privacyDict的objectofkey(value,friends,networks,allow,deny)

NSDictionary *privacyDict = [[NSDictionary alloc] initWithObjectsAndKeys:
                   @"CUSTOM",@"value",
                   @"SOME_FRIENDS",@"friends",
                   @"[comma separated friends id]",@"allow",
                   nil];

关于iOS Facebook SDK - 发布到隐私值设置为 SELF 的 friend 墙未设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23220953/

相关文章:

ios - 字符串到字典和向后

ios - 如何在 IOS 上显示正确的瑞典货币?

ios - 找出保存在 NSString 中的 URL 的扩展部分

Facebook 应用审查 - 要使用 'Page Public Content Access' ,您对这个端点的使用必须经过 Facebook 审查和批准

ios - 为什么 CIContext.createCGImage 会导致内存泄漏?

java - 单击 AlertDialog 的“肯定”按钮时获取 'E/AndroidRuntime: Error reporting crash android.os.TransactionTooLargeException'

ios - Social.framework Facebook 的可能性

ios - Facebook iOS SDK - 设置 Controller 的正确方法是什么

ios - 无法发出多个 FBSDKGraphRequest

IOS Facebook 好友邀请在 facebook sdk 中不起作用