简体   繁体   English

iOS Facebook SDK-未将“隐私”值设置为“自定义”的“发布到朋友”墙

[英]iOS Facebook SDK - Post to Friends wall with Privacy value set to SELF not being set

I want to set the privacy of the wall post on my friends wall to SELF. 我想将我朋友墙上的墙上帖子的隐私设置为SELF。

so that only he can see it, i know it is possible because there is a property, but there is no where documented how to achieve this. 这样,只有他能看到它,我知道这是可能的,因为有一个属性,但是没有文档记录如何实现。

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

this is the code that i use: 这是我使用的代码:

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();
                 }
             }
         }
     }];

But when i look in the GRAPH api this says: 但是当我查看GRAPH API时,它说:

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

Try This. 尝试这个。 May be this Helps. 可能对您有所帮助。

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];

Set the objectofkey (value,friends,networks,allow,deny) of dictionary privacyDict according to your use 根据您的用途设置字典privacyDict的objectofkey (值,朋友,网络,允许,拒绝)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM