I have a problem with facebook API. According to the documentation (https://developers.facebook.com/docs/reference/api/post/) of facebook you can tagging a friend whit:
"to": {
"data": [
{
"name": "Facebook Name",
"id": "XXXXXXXXXX_id"
},
{
"name": "Facebook Name",
"id": "XXXXXXXXXX_id"
}
]
}
To run the request I use SLRequest whit this code:
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)
{
But this code generate the error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0x1245efe0'
***
.
What is wrong? Thanks in advance for the answers. Sorry for my bad English