簡體   English   中英

iOS Facebook SDK-未將“隱私”值設置為“自定義”的“發布到朋友”牆

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

我想將我朋友牆上的牆上帖子的隱私設置為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];

根據您的用途設置字典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