我的facebook API有问题。根据facebook的文档(https://developers.facebook.com/docs/reference/api/post/),您可以标记朋友白衣:
"to": {
"data": [
{
"name": "Facebook Name",
"id": "XXXXXXXXXX_id"
},
{
"name": "Facebook Name",
"id": "XXXXXXXXXX_id"
}
]
}
要运行请求,我使用SLRequest whit代码:
NSMutableDictionary *dictionaryMessage =[[NSMutableDictionary alloc]init];
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
if (message != nil) {
[dictionaryMessage setObject:message forKey:@"message"];
}
if (placeId !=nil) {
[dictionaryMessage setObject:placeId forKey:@"place"];
}
if ([facebookFriendArray count]>0) {
NSMutableArray *tagFriend = [[NSMutableArray alloc]initWithCapacity:[facebookFriendArray count]];
for (TagPeople * friend in facebookFriendArray) {
NSDictionary *userDic = [[NSDictionary alloc]initWithObjectsAndKeys:friend.idSocial,@"id",friend.nome,@"name", nil];
[tagFriend addObject:userDic];
}
NSDictionary *dictionarySup = [[NSDictionary alloc]initWithObjectsAndKeys:tagFriend,@"data", nil];
[dictionaryMessage setObject:dictionarySup forKey:@"to"];
}
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST
URL:requestURL parameters:jsonObject];
if (immagine != nil) {
NSData *imageData = UIImageJPEGRepresentation(immagine, 0.5);
[postRequest addMultipartData:imageData withName:@"images" type:@"multipart/jpeg" filename:@"file_name"];
}
postRequest.account = accountFacebook;
[postRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
但是这段代码会产生错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0x1245efe0'
***
。
怎么了?提前谢谢你的答案。抱歉我的英文不好