I have implemented faceBook share.My code is working is working well for older faceBook AppId. When i created a new faceBook id in my account,sharing works in my account.If i login with another user account i am getting authorization error.Please help. My code is
-(void)Share
{
[SVProgressHUD showWithStatus:@"Posting..." maskType:SVProgressHUDMaskTypeClear];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (!appDelegate.session)
{
appDelegate.session = [[FBSession alloc]initWithPermissions:[NSArray arrayWithObjects:@"publish_actions",nil]];
[self FBShare];
}
else
{
[self FBShare];
}
}
-(void)FBShare
{
if (!FBSession.activeSession.isOpen)
{
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"publish_actions", nil];
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self postMessage];
}];
}else
if(FBSession.activeSession.isOpen)[self postMessage];
}
-(void)postMessage
{
NSMutableDictionary *parameters=
[NSMutableDictionary dictionaryWithObjectsAndKeys:[Hey %@",_barCode],@"name",
_barImage,@"picture",
@"image/jpeg",@"content_type"
,nil];
FBRequest *request = [FBRequest requestWithGraphPath:@"me/photos" parameters:parameters HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error)
{
NSLog(@"Posted");
}
else
{
NSLog(@"Error %@",error);
}];
}
My error response is
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x8ed73f0 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 200;
message = "(#200) The user hasn't authorized the application to perform this action";
type = OAuthException;
};
};
code = 403;
headers = (
{
name = Expires;
value = "Sat, 01 Jan 2000 00:00:00 GMT";
},
{
name = "Cache-Control";
value = "no-store";
},
{
name = "Access-Control-Allow-Origin";
value = "*";
},
{
name = Pragma;
value = "no-cache";
},
{
name = "Content-Type";
value = "text/javascript; charset=UTF-8";
},
{
name = "WWW-Authenticate";
value = "OAuth \"Facebook Platform\" \"insufficient_scope\" \"(#200) The user hasn't authorized the application to perform this action\"";
}
);
}, com.facebook.sdk:ErrorSessionKey=, expirationDate: 2014-08-30 12:08:26 +0000, refreshDate: 2014-07-02 05:19:03 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:( "public_profile", email, "contact_email" )>}
您需要公开您的 facebook AppId .. !!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.