【问题标题】:How can I update the privacy parameter in FBSDKGraphRequest when starting a live video?开启直播视频时如何更新FBSDK GraphRequest中的privacy参数?
【发布时间】:2019-06-29 22:30:12
【问题描述】:

我正在尝试更新隐私参数,以便将我的应用启动的实时视频发布在用户的时间轴上,并将隐私设置为“ALL_FRIENDS”。我查看了文档,但我想出的代码不起作用:

NSString* livePath =  [@"/" stringByAppendingPathComponent:[token.userID stringByAppendingPathComponent:@"live_videos"]];
FBSDKProfile *profile = [FBSDKProfile currentProfile];

if(profile.userID){
    livePath = [@"/" stringByAppendingPathComponent:[profile.userID stringByAppendingPathComponent:@"live_videos"]];
}

NSMutableDictionary* param = @{
                               }.mutableCopy;
[param setObject:@"Test Title" forKey:@"title"];
[param setObject:@"Test Description" forKey:@"description"];
[param setObject:@"privacy" forKey:@"{@\"value\": \"ALL_FRIENDS\"}"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:livePath
                                   parameters:param
                                  tokenString:token.tokenString
                                      version:@"v2.6"
                                   HTTPMethod:@"POST"]
 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { //More code here }

【问题讨论】:

  • 用户授权应用具有特定隐私级别,您无法提高该级别以包含更多用户。
  • @luschn 正确,但是如果用户授权应用程序包含“所有人”并且我想为他们提供较低隐私级别的选项(例如:所有朋友),我该怎么做?在任何情况下都不能设置隐私吗?
  • 文档是这样说的吗?你查看过 api 参考吗?
  • @luschn 当然我有 (developers.facebook.com/docs/graph-api/reference/live-video/…) 它将隐私列为您可以更新的参数,但没有显示如何或它的语法是什么的示例。
  • @luschn android 也是这样做的。 stackoverflow.com/questions/3563538/…

标签: ios objective-c facebook facebook-graph-api live-streaming


【解决方案1】:

我使用 Facebook 的图形浏览器 (https://developers.facebook.com/tools/explorer/?method=POST&path=118477909176601%2Flive_videos&version=v3.2&privacy=%7B%27value%27%20%3A%20%27ALL_FRIENDS%27%7D&classic=0) 解决了这个问题。设置参数以更新隐私设置的代码如下。

[[[FBSDKGraphRequest alloc] initWithGraphPath:livePath
                                   parameters:@{ @"privacy": @"{'value' : 'ALL_FRIENDS'}",}
                                  tokenString:token.tokenString
                                      version:@"v2.6"
                                   HTTPMethod:@"POST"]
 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

【讨论】:

  • 我相信您可以在 stackoverflow 上接受自己的答案,如果可能的话,您绝对应该这样做。将其标记为“已解决”。
  • 是的,我可以说我必须等到明天。
猜你喜欢
  • 1970-01-01
  • 2020-10-29
  • 1970-01-01
  • 2011-07-10
  • 2017-05-27
  • 2011-03-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多