Facebook にステータスを公開するための iOS 用 Facebook SDK に問題があります。「このアプリとそのすべてのライブ機能を一般公開しますか?」をオンにしました。ダッシュボードで切り替えます。管理者アカウントにログインしてステータスの更新を公開することはできますが、別のユーザーとしてログインすると、次のエラーが表示されます。
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0xa5b9de0 {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 = "Facebook-API-Version";
value = "v2.2";
},
{
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=<FBSession: 0xa670520, state: FBSessionStateOpen, loginHandler: 0xa573850, appID: %$#%#%#$%#$%#$%, urlSchemeSuffix: free, tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0xa577b60>, expirationDate: 2015-01-23 16:13:18 +0000, refreshDate: 2014-11-24 16:43:00 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
"public_profile"
)>}
アクセス許可を取得するために使用しているコードは次のとおりです。
- (void)facebookCheckIn {
NSArray *permissions =[NSArray arrayWithObjects:@"publish_actions", nil];
if ([[FBSession activeSession]isOpen]) {
/*
* if the current session has no publish permission we need to reauthorize
*/
if ([[[FBSession activeSession]permissions]indexOfObject:@"publish_actions"] == NSNotFound) {
[[FBSession activeSession] requestNewPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session,NSError *error){
[self showCustomMessage];
}];
}
else{
[self showCustomMessage];
}
}else{
/*
* open a new session with publish permission
*/
NSArray *requestPermission = @[@"publish_actions"];
// Open session with public_profile
[FBSession openActiveSessionWithPublishPermissions:requestPermission defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
if (!error){
// If the session was opened successfully
if (state == FBSessionStateOpen){
// Your code here
[self showCustomMessage];
} else {
// There was an error, handle it
NSLog(@" error on opening session = %@",error);
}
}
}];
}
}
ステータスを投稿するために使用するコードは次のとおりです。
-(void)postToFacebook{
NSLog(@"post to facebook");
NSMutableDictionary<FBGraphObject> *place = [FBGraphObject graphObject];
place[@"place"] = @"1342352523525"; // food Place id
place[@"message"] = facebook_message;
[FBRequestConnection startWithGraphPath:@"me/feed"
parameters:place
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//verify result
NSLog(@"result: %@ %@", result,error.description);
if(error) {
NSLog(@"Error FOR PLACE: %@", error.description);
if ([error.description rangeOfString:@"506"].location != NSNotFound ) {
[self showAnimatedMessage:@"You have already checked in using Facebook"];
}
else if([error.description rangeOfString:@"-1009"].location != NSNotFound )
{
[self showAnimatedMessage:@"The Internet connection appears to be offline."];
}
else if ([error.description rangeOfString:@"code = 1;"].location != NSNotFound ) {
[self showAnimatedMessage:@"An Error Occured, please try again later."];
}
else
{
[self showAnimatedMessage:@"The user hasn't authorized the application to perform this action, need publish_actions permission?"];
}
}
else {
[self showAnimatedMessage:@"Successfully checked in with Facebook!"];
NSLog(@"Status update submitted!");
}
// [self showAnimatedMessage:@"done"];
}];
}
どんな助けでも大歓迎です。ありがとう