2012-10-15 286 views
-3

我想喜歡一個Facebook頁面,但我得到這個錯誤:我收到了錯誤消息:{「error」:{「message」:「(#200)Permissions error」,「type」:「OAuthException」,「code」:200}}當我做一個類似的動作

{"error":{"message":"(#200) Permissions error","type":"OAuthException","code":200}}

正如你可以在我的代碼中看到,權限似乎是確定。請注意,當我想要喜歡諸如www.google.com這樣的簡單網址時,它可以正常工作!

只有當我想要喜歡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); 
        /////////////////////////////////////////////////     
       }]; 
      } 
     } 

回答

1

它不可能使用「喜歡」的動作編程到Facebook頁面。這是在the documentation

For Facebook Pages or websites that do not integrate with Facebook Authentication, developers should continue to use the Like button social plugin.

+0

它們是什麼意思的「喜歡按鈕社交插件」?我應該在網頁視圖中使用類似按鈕的網頁版本? –

+0

他們的意思是:https://developers.facebook.com/docs/reference/plugins/like/ - 我相信它可以在webview – Igy

相關問題