我的要求是我需要通过我的应用程序在我的 Facebook 墙上发布隐私设置(通知特定朋友)如何实现这一点我遵循以下代码
-(void)sendNotification
{
CoreDataManager *coremanagerobj = [[CoreDataManager alloc]init];
NSArray *useridarray = [coremanagerobj GetAllMembersList];
NSMutableArray *arraylist = [[NSMutableArray alloc]init]; // it will have the selected friends id
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
for (NSManagedObject *obj in useridarray)
{
[ arraylist addObject:[obj valueForKey:@"memberId"]];
}
[dict setValue:@"CUSTOM" forKey:@"value"];
[dict setValue:arraylist forKey:@"allow"];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:NSJSONWritingPrettyPrinted
error:&error];
NSString *jsonString;
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"sending notification", @"message",@"Posted via testApp", @"description",jsonData ,@"privacy",
nil];
// Make the request
if ([FBSession.activeSession isOpen])
{
[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
{
if (!error && status == FBSessionStateOpen)
{
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
if (!error)
{
// Link posted successfully to Facebook
NSLog(@"Result: %@", result);
}
}];
}
}];
}
}
帖子没有在 Facebook 上发布。
我尝试使用Breakpoint进行调试。
它显示“错误
NSError *domain: @"com.facebook.sdk" - code: 5 0x000000010958d110"
如果有人知道解决方案,请帮助我提前谢谢...