如何在startWithGraphPath Facebook iOS中标记朋友 [英] How to tag friends in startWithGraphPath Facebook iOS

查看:119
本文介绍了如何在startWithGraphPath Facebook iOS中标记朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法让我的帖子使用iOS SDK的Facebook SDK。我正在使用startWithGraphPath:参数:HTTPMethod:completionHandler:函数。我可以得到消息,地点和图片工作,但我似乎无法标记朋友。我已经尝试将NSDictionary键和对象设置为

I can't seem to get my posts to work using the Facebook SDK for iOS. I am using the "startWithGraphPath:parameters:HTTPMethod:completionHandler:" function. I can get the message, place, and picture working but I can't seem to tag friends. I have tried setting the NSDictionary key and object to

parameters[@"tags"] = self.friendsIDs; 

这是一个逗号分隔的用户名字符串(根据Facebook参考页: https://developers.facebook.com/docs/reference/api/user/#posts )。然而,这总是出现:

which is a string of comma separated Facebook User ID's (per the Facebook reference page: https://developers.facebook.com/docs/reference/api/user/#posts). However this always comes up:

com.facebook.sdk:ParsedJSONResponseKey={
    body =     {
        error =         {
            code = 100;
            message = "(#100) param tags must be an array.";
            type = OAuthException;

所以我把它们放在一个数组中,它仍然没有起作用。事实上,我得到一个不同的错误:

So then I put them in an array and it still didn't work. In fact then I get a different error:

- [__ NSArrayM length]:无法识别的选择器发送到实例0x1228abc0
2013-09- 26 16:47:36.917 DrinkingGamePicker [27558:a0b] ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [__ NSArrayM length]:发送到实例0x1228abc0
的无法识别的选择器发送到实例0x1228abc0'

-[__NSArrayM length]: unrecognized selector sent to instance 0x1228abc0 2013-09-26 16:47:36.917 DrinkingGamePicker[27558:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM length]: unrecognized selector sent to instance 0x1228abc0sent to instance 0x1228abc0'

任何人都知道如何格式化这些参数?我找不到任何文件或清楚的例子。感谢提前。

Anyone know how to format these parameters? I can't find any documentation or clear examples. Thanks in advance.

作为附注,有没有人知道如何从应用程序发布并标记人,但不是一个地方?我觉得每个方法都意味着你必须至少标记一个地方。

As a side note, does anyone know how to post from an app and tag people but not a place? I feel like every method means you have to at least tag a place first.

谢谢!

推荐答案

从我的经验来看,你不能同时标记该帖子的朋友。但是,您可以在帖子成功后标记好朋友。发布后,您应该从completionHandler块获取帖子ID。这是我现在正在使用的代码。

From my experience, you can't tag friends with the post at the same time. However you can tag friends after the post is success. After posting, you should get the post id from the completionHandler block. Here is the code what i am using right now.

NSString *postId = //result from posting completionHandler;
NSString *path = [NSString stringWithFormat:@"%@/tags",postId];
NSMutableArray *tags = [NSMutableArray array];
for (NSString *friendId in self.tagFriends) {
    [tags addObject:[NSDictionary dictionaryWithObject:friendId forKey:@"tag_uid"]];
}

NSMutableDictionary *param = [NSMutableDictionary dictionary];
[param setObject:JSONStringWithObject(tags) forKey:@"tags"]; 
//JSONStringWithObject() is just a function develop by myself using NSJSONSerialization to wrap NSArray into JSON format NSString

[FBRequestConnection startWithGraphPath:path parameters:param HTTPMethod:@"POST"     completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    //check error here 
}];

这篇关于如何在startWithGraphPath Facebook iOS中标记朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆