[英]Facebook - ios integration (Social Framework) Invalid permission
我正在使用兩個不同的iOS應用程序:
因此,盡管我嘗試關注所有類型的帖子,文檔等等,但我還是做錯了任何事情。
我特別關注了此發布iOS 6 Facebook的發布過程,最終結果為“ remote_app_id與存儲的ID不匹配”錯誤 ,它具有很好的答案。
我想我已經在Facebook Developers中創建了我的應用程序,因為我遇到了問題(錯誤的iPhone ID和錯誤7),並且在發帖之后,我提到這些問題都消失了。
當用戶單擊Facebook上的共享時,我這樣做:
- (void) loginWithFacebookWithReadPermissionsWithDelegate:(id<IfcRRSSDelegate>)_delegate
{
self.delegateFB = _delegate;
ACAccountStore *account = [[ACAccountStore alloc]init];
ACAccountType *accountType = [cuenta accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *facebookKey = MY_FACEBOOK_KEY;
NSMutableArray *permimssions = [[NSMutableArray alloc] init];
[permimssions addObject:@"email"];
self.fbPermission = [NSMutableDictionary dictionaryWithObjectsAndKeys:
facebookKey, ACFacebookAppIdKey,
ACFacebookAudienceFriends, ACFacebookAudienceKey,
permimssions, ACFacebookPermissionsKey,
nil];
[account requestAccessToAccountsWithType:accountType options:self.fbPermission completion:
^(BOOL granted, NSError *error) {
if(granted)
{
NSArray *accounts = [account accountsWithAccountType: accountType];
ACAccount *_facebookAccount = [accounts lastObject];
self.accountFB = _facebookAccount;
ACAccountCredential *credentials = [self.accountFB credential];
self.tokenFB = [credentials oauthToken];
}
else
{
// Show error
}
}];
}
如果此登錄正常(實際上總是正常),我稱之為:
- (void) loginWithFacebookWithWritePermissionsWithDelegate:(id<IfcRRSSDelegate>)_delegate
{
self.delegateFB = _delegate;
ACAccountStore *account = [[ACAccountStore alloc]init];
ACAccountType *accountType = [cuenta accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *facebookKey = MY_FACEBOOK_KEY;
NSMutableArray *permimssions = [[NSMutableArray alloc] init];
[permimssions addObject:@"publish_stream"];
[permimssions addObject:@"publish_actions"];
self.fbPermission = [NSMutableDictionary dictionaryWithObjectsAndKeys:
facebookKey, ACFacebookAppIdKey,
ACFacebookAudienceFriends, ACFacebookAudienceKey,
permimssions, ACFacebookPermissionsKey,
nil];
[account requestAccessToAccountsWithType:accountType options:self.fbPermission completion:
^(BOOL granted, NSError *error) {
NSLog(@">>>>ERROR: %@", error);
if(granted)
{
NSArray *accounts = [account accountsWithAccountType: accountType];
ACAccount *_facebookAccount = [accounts lastObject];
self.accountFB = _facebookAccount;
ACAccountCredential *credentials = [self.accountFB credential];
self.tokenFB = [credentials oauthToken];
}
else
{
// Show error
}
}];
}
第二次登錄失敗,出現此錯誤:
錯誤:錯誤Domain = com.apple.accounts代碼= 7“ Facebook服務器無法滿足此訪問請求:無效的權限:publish_stream” UserInfo = 0xc18d700 {NSLocalizedDescription = Facebook服務器無法滿足此訪問請求:無效的權限:publish_stream}
無效的權限:publish_stream ??? 我幾乎找不到有關此錯誤的信息。
我試圖對此權限發表評論,並且只有publish_action,但是當我嘗試發布時,出現了這個新錯誤:
{
code = 200;
message = "(#200) The user hasn't authorized the application to perform this action";
type = OAuthException;
}
如果第二次登錄順利,我將調用此代碼進行發布(但由於第二次登錄失敗而從未調用):
- (void) postWithFacebookWithMessage:(NSString *)msg
{
if(self.accountFB)
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setObject: self.accountFB.credential.oauthToken forKey:@"access_token"];
[parameters setObject:msg forKey:@"message"];
NSURL *requestUR = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:requestURL
parameters:parameters];
request.account = self.accountFB;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {
if(!error)
{
NSDictionary *list = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if([list objectForKey:@"error"] != nil)
{
// Try to attempt Renew Credentials
}
else
{
// Everything works
}
dispatch_async(dispatch_get_main_queue(),^{});
}
else
{
// Try to attempt Renew Credentials
}
}];
}
}
如果這很重要,我已經在我的Facebook頁面,活動,應用程序,此應用程序中檢入,並說“該應用程序可以您的名義發布:只有您自己”。
知道發生了什么嗎?
親切的問候!
編輯:對不起,我在解釋錯誤時犯了一個重要錯誤,所以我編輯了帖子:失敗的Facebook調用是第二次登錄,而不是帖子。
試試我在我的應用程序中使用的這段代碼:
__block ACAccount * facebookAccount;
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
NSDictionary *emailReadPermisson = @{
ACFacebookAppIdKey : @"0123456789",
ACFacebookPermissionsKey : @[@"email"],
ACFacebookAudienceKey : ACFacebookAudienceEveryone,
};
NSDictionary *publishWritePermisson = @{
ACFacebookAppIdKey : @"0123456789",
ACFacebookPermissionsKey : @[@"publish_actions"],
ACFacebookAudienceKey : ACFacebookAudienceEveryone
};
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
//Request for Read permission
[accountStore requestAccessToAccountsWithType:facebookAccountType options:emailReadPermisson completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Granted for read");
//Request for write permission
[accountStore requestAccessToAccountsWithType:facebookAccountType options:publishWritePermisson completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Granded for post");
NSArray *accounts = [accountStore
accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
NSLog(@"Successfull access for account: %@", facebookAccount.username);
/* Do any things here */
}
else
{
NSLog(@"Access to Facebook is not granted");
// Fail gracefully...
NSLog(@"%@",error.description);
}
}];
}else{
/* Error */
}
}];
此樣本在此帖子中找到
如果您的帳戶狀態為“未授予”,請檢查您的應用程序是否在Settings->Facebook
未被阻止。 如果是-要求用戶授予設置訪問權限。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.