2016-11-26 19 views
1

iOSアプリを作成しています。私は私のアプリを使ってFacebookのイベントへのリンクをいくつか投稿する必要があります。私はFacebook SDKを統合しました。 Facebook Graph APIを使用することで、同じコードが見つかり、Graph API Explorerで正常に動作します。しかし、それは私のアプリで動作しません。 Facebookへのリンクを投稿しようとすると、次のエラーが表示されます。私はXcode 7.3とiOS 9を使用しています。iOSアプリを使用してFacebookに投稿できない

error=Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=403, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#200) Insufficient permission to post to target on behalf of the viewer, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=200, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={ 
body =  { 
    error =   { 
     code = 200; 
     "fbtrace_id" = DWR8SW4K1Ls; 
     message = "(#200) Insufficient permission to post to target on behalf of the viewer"; 
     type = OAuthException; 
    }; 
}; 
code = 403; 

私のコードは以下の通りです。問題は

-(void)postToFacebook 
{ 

    if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) { 

     [self post]; 
     // TODO: publish content. 
    } else { 
     FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init]; 
     [loginManager logInWithPublishPermissions:@[@"publish_actions"] 
           fromViewController:self 
              handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
               if(error) 
               { 
                NSLog(@"error=%@",error); 
               } 
               else{ 
                [self post]; 
               } 

               //TODO: process error or result. 
              }]; 
    } 
} 

-(void)post 
    { 

     FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] 
             initWithGraphPath:3466734743/feed 
             parameters:@{ @"link": @"http://www.dhip.in/ofc/metatest.html",} 
             HTTPMethod:@"POST"]; 
     [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
      // Insert your code here 

      if(error) 
      { 
       NSLog(@"error=%@",error); 
      } 
      else 
      { 
       NSLog(@"success"); 

      } 
     }]; 

    } 

と私はhttps://developers.facebook.com/docs/ios/ios9に見て、私のinfo.plist.Pleaseヘルプme.WhatにLSApplicationQueriesSchemesのすべての組み合わせを試してみましたでしょうか?なぜFacebookに投稿できないのですか?

+0

この回答でエラーを確認してください:http://stackoverflow.com/a/19653226/3202193 –

答えて

0
SLComposeViewController *fbCompose; 

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { 
       fbCompose=[[SLComposeViewController alloc]init]; 
       fbCompose=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 
       [fbCompose setInitialText:@"My Score in AlphaMarics is"]; 
       [fbCompose addImage:image]; 

       [self presentViewController:fbCompose animated:YES completion:nil]; 

    } 
    [fbCompose setCompletionHandler:^(SLComposeViewControllerResult result) 
     { 
       NSString * fbOutput=[[NSString alloc]init]; 
       switch (result){ 
         case SLComposeViewControllerResultCancelled: 
           [email protected]"You Post is cancelled"; 
           break; 

         case SLComposeViewControllerResultDone: 
           [email protected]"Your post Posted Succesfully"; 
           break; 

         default: 
           break; 
       } 
       UIAlertView * fbAlert=[[UIAlertView alloc]initWithTitle:@"Warning" message:fbOutput delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 
       [fbAlert show]; 
     }]; 
関連する問題