I am trying to post/share a picture on Facebook. First, I am getting publish permissions using:
NSArray *permissionsNeeded = @[@"publish_actions"];
[FBRequestConnection startWithGraphPath:@"/me/permissions"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error){
NSDictionary *currentPermissions= [(NSArray *)[result data] objectAtIndex:0];
NSMutableArray *requestPermissions = [[NSMutableArray alloc] initWithArray:@[]];
for (NSString *permission in permissionsNeeded){
if (![currentPermissions objectForKey:permission]){
[requestPermissions addObject:permission];
}
}
if ([requestPermissions count] > 0){
[FBSession.activeSession requestNewPublishPermissions:requestPermissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
[self shareDataOnFacebook];
} else {
NSLog(@"%@", error.description);
}
}];
} else {
[self shareDataOnFacebook];
}
} else {
NSLog(@"%@", error.description);
}
}];
If I NSLog the session, I am getting this:
FBSessionStateOpenTokenExtended, loginHandler: 0x15eab870, appID: 719202928131376, urlSchemeSuffix: , tokenCachingStrategy:, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2014-05-10 12:57:41 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:( status, permission, "publish_actions" )>
Now, If I try to post the picture using:
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"{image-url}", @"url",
nil
];
/* make the API call */
[FBRequestConnection startWithGraphPath:@"/me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
}];
I am getting the error:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x15e4f370 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={ body = { error = { code = 200; message = "(#200) Permissions error"; type = OAuthException; }; }; code = 403; }, com.facebook.sdk:ErrorSessionKey=, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2014-05-10 12:57:41 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:( status, permission, "publish_actions" )>}
Even, If when I get the permissions again, "publish_actions" isn't in the list. Please guide me what I am doing wrong.
Is there any other way of sharing/posting just picture with description(without any link, which is required for Share dialogue)?