开始直播视频时,如何更新FBSDKGraphRequest中的privacy参数?

时间:2019-02-06 02:05:30

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

我正在尝试更新隐私参数,以便将我的应用程序启动的实时视频发布到用户的时间轴上,并将隐私设置为“ 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 }

1 个答案:

答案 0 :(得分:0)

我使用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) {