如何测试facebooks朋友标记

时间:2015-06-30 11:05:24

标签: ios facebook facebook-graph-api tags

我希望我的应用在视频帖子中标记好友。 (发布没有标签的视频工作正常)

我正在使用的帐户已添加到我的应用的测试人员列表中。 所以我应该可以在没有任何权限的情况下进行此调用。

但回应仍然是: "错误:(#3)应用程序无法进行此API调用。"

获得" Taggable Friends"权限,我需要将我的应用程序的构建上传到fb。 但我无法自己先测试它来实现此功能。

如何解决这个鸡蛋问题?

我的代码看起来像这样(iOS - Objc):

NSDictionary *params = @{
                         @"title": @"some title",
                         @"description": @"some desctiption",
                         @"tags": _friendId
                         };
SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                              requestMethod:SLRequestMethodPOST
                                                        URL:videourl
                                                 parameters:params];

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。 您无法在上传请求中设置标记(我仍然不知道为什么)。 但是,您可以在上传视频后在视频中为用户添加标记。

上传成功后,您会收到videoId:

ACAccountCredential *fbCredential = [_facebookAccount credential];
NSString *accessToken = [fbCredential oauthToken];
NSString *urlStr = [NSString stringWithFormat: @"https://graph-video.facebook.com/%@/tags?access_token=%@&tag_uid=%@", _currentVideoId, accessToken, userId];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                        requestMethod:SLRequestMethodPOST
                                                  URL:[NSURL URLWithString: urlStr]
                                           parameters: @{}];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {

        NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
        //Do something
    }];
});

使用此ID,您可以发出第二个请求:

  public
      void
      map(LongWritable key, Text value, OutputCollector<Text, MyObject> output, Reporter reporter)
                                                                                                                 throws IOException {

try {

  ForXmlHandling message = (ForXmlHandling) unmarshaller.unmarshal(new StringReader(value.toString()));

  MyObject row = XmlParser.parse(message);

   row.setOrigin(true);
  output.collect(new Text(row.getPnrRecordKey().toString()), row);
  }

catch(JAXBException e) {
   LOG.debug(e);
}

要发出第二个请求,您需要@“user_videos”的权限。 如果您想标记更多用户,则需要多次提出此请求。也许这也可能有一个请求,但我还没有想出如何做到这一点。

相关问题