2013-09-23 75 views
2

我有以下代碼:如何在iPhone上使用圖形API發表評論照片?

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:txtComment.text, @"message", nil]; 
NSString *strPicId = [[Appdel.arrFacebookImages objectAtIndex:Appdel.getIndex] valueForKey:@"id"]; 
NSString *strPath =[NSString stringWithFormat:@"%@/comments",strPicId]; 
[FBRequestConnection startWithGraphPath:strPath parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result1, NSError *error) 
{ 
    if(!error) 
    { 
    } 
    else 
    { 
     NSLog(@"ERROR:%@",error); 
    } 
}]; 

但它運行時,它給我的錯誤,如下面,

ERROR:Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0xb36dd80 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={ 
body =  { 
    error =   { 
     code = 200; 
     message = "(#200) Requires extended permission: publish_stream"; 
     type = OAuthException; 
    }; 
}; 

我已經成功登錄,我也越來越相冊,照片,評論,但我不能發表任何評論任何照片。

回答

0

看起來您缺少訪問令牌中的發佈權限。

[FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"] 
             defaultAudience:FBSessionDefaultAudienceFriends 
              allowLoginUI:YES 
            completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { 
     if (FBSession.activeSession.isOpen && !error) { 
      // Publish the comment (your code inside) if permission was granted 
      [self publishComment]; 
     } 
    }]; 

這是從代碼:https://developers.facebook.com/docs/ios/publish-to-feed-ios-sdk/

你可以得到它

相關問題