I m developing an iPhone app which includes facebook wall posting.After log in, I post to user's wall by following code:
NSString *appIcon = [NSString stringWithString:@"http://a2.twimg.com/profile_images/416166235/apple-black_normal.png"];
NSString *appSiteUrl = [NSString stringWithString:@"http://www.apple.com"];
NSString *attachment= [NSString stringWithFormat:@"{\"caption\":\"%@ Likes in the iPhone App\",\"description\":\"\",\"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"}]}",_facebookName,appIcon,appSiteUrl];
// [attachment stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSArray *obj = [NSArray arrayWithObjects:attachment,nil];
NSArray *keys = [NSArray arrayWithObjects:@"attachment",nil];
NSDictionary *params = [NSDictionary dictionaryWithObjects:obj forKeys:keys];
NSLog(@"atachment : %@",[params description]);
[[FBRequest requestWithDelegate:self] call:@"facebook.stream.publish" params:params];
This results into Error,saying that "The user hasn't authorized the application to perform this action".
In the Facebook Profile of user, the app has only permission to access user's basic information. So I need to take "stream_publish " from the user.
So how to give extended permission Dialog (for permission of "stream_publish") ??
Any help would be appreciated.
I have Found the solution of the problem by myself.
Actually the cause of the problem is the application doest have permission to "Post To Wall". (publish_stream).Hence FB was denying with following error.
"The user hasn't authorize this application to perform this action".
So when user logs in, Ask user to give permission of publish_stream,
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
FBPermissionDialog *permissions = [[FBPermissionDialog alloc]initWithSession:_session];
permissions.permission = [NSString stringWithString: @"publish_stream"];
[permissions show];
}
`
When once the user have allowed "Post to wall", this dialog wont appear ever again.