讓我說清楚。我沒有使用Facebook SDK
。我使用iOS SDK的Social.framework
和ACAccountStore
訪問Facebook帳戶,並使用它/他們發佈。iOS 6 SDK SLRequest返回'400'
我使用相同的代碼在Twitter上發佈。它工作100%。但由於某種原因,無論我爲Facebook整合做什麼,當我嘗試發佈信息時,都會收到「400」錯誤。
我的方法是:
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{ ACFacebookAppIdKey: @"MY_APP_ID",ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],ACFacebookAudienceKey: ACFacebookAudienceFriends };
[account requestAccessToAccountsWithType:facebookAccountType options:options
completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
NSDictionary *parameters = @{@"message": string999};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:feedURL
parameters:parameters];
acct.accountType = facebookAccountType;
// Post the request
[feedRequest setAccount:acct];
// Block handler to manage the response
[feedRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if (granted && error == nil) {
} else {
NSLog(@"Facebook response, HTTP response: %i %@", [urlResponse statusCode], [error description]);
[self closeShareMenu];
}
}];
}
}
我不知道我要去哪裏錯了!這太討厭了!我已經在Facebook開發人員和所有人中正確設置了我的應用程序!請幫忙-_-'
對不起,不知道格式太差了。 – topLayoutGuide
responseData是什麼?如果你得到一個'400 - 錯誤的請求',也許你會從響應中得到一些指示。 – fguchelaar
我不知道如何檢查responseData中的內容。 – topLayoutGuide