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?
檢查錯誤以這個答案:http://stackoverflow.com/a/19653226/3202193 –