-3

Facebookページが好きですが、次のエラーが発生しました。

{"error":{"message": "(#200)パーミッションエラー"、 "type": "OAuthException"、 "code":200}}

私のコードでわかるように、権限は問題ないようです。www.google.comのような単純なURLが好きな場合は、機能することに注意してください。

このエラーが発生したのは、Facebookページを高く評価したい場合だけです。

これが私のコードです:

-(IBAction) buttonTestRecoFB
{
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"publish_actions",@"publish_stream",
                            nil];

    [FBSession.activeSession closeAndClearTokenInformation];

    [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES
                              completionHandler:^(FBSession *session,
                                                  FBSessionState status,
                                                  NSError *error) {
                                  // session might now be open.
                                  [self sessionStateChanged:session state:status error:error];
                              }];
}

// FACEBOOK
//

- (void)sessionStateChanged:(FBSession *)session 
                      state:(FBSessionState) state
                      error:(NSError *)error
{
    switch (state) 
    {
        case FBSessionStateOpen: 
        {
            NSLog(@"FBSessionStateOpen");

            if (session.isOpen) 
            {
                FBRequest *me = [FBRequest requestForMe];

                [me startWithCompletionHandler: ^(FBRequestConnection *connection, 
                                                NSDictionary<FBGraphUser> *my,
                                                  NSError *error) {

                    NSLog(@"firtname = %@" , my.first_name);

                    /////////////////////////////////////////////////

                    NSString *theWholeUrl = [NSString stringWithFormat:@"https://graph.facebook.com/313449204401/likes?access_token=%@", session.accessToken];

                    NSLog(@"TheWholeUrl: %@", theWholeUrl);

                    NSURL *facebookUrl = [NSURL URLWithString:theWholeUrl];

                    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:facebookUrl];
                    [req setHTTPMethod:@"POST"];

                    NSURLResponse *response;
                    NSError *err;
                    NSData *responseData = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];

                     NSString *content = [NSString stringWithUTF8String:[responseData bytes]];

                    NSLog(@"responseData: %@", content);
                    /////////////////////////////////////////////////                  
                }];
            }
        }
4

1 に答える 1

1

プログラムで Facebook ページに「いいね」アクションを適用することはできません。これはドキュメントに記載されています:

Facebook 認証と統合されていない Facebook ページまたは Web サイトの場合、開発者は引き続き Like ボタン ソーシャル プラグインを使用する必要があります。

于 2012-10-15T05:54:32.067 に答える