2013-06-05 47 views
0

Alrighty。我有一個按鈕(下面),我從應用程序中獲取一些信息,然後將它發佈到用戶FB提要。iOS發佈到Facebook發佈屏幕驗證後不顯示

它幾乎從不第一次工作。他們通常會在這之後很好地工作。發生什麼事是,當我按下按鈕時,它告訴我,我已經給了應用程序許可使用FB(我只想看到第一次,而不是每次)。然後當我按下確定後,它會返回到應用程序,或者它會去顯示我可以實際發佈到我的牆上的頁面(這是我想要的)。

我試着做不同的事情,以使其更加一致地工作。這裏有什麼會導致這種行爲嗎?

-(IBAction)fbButton:(id)sender { 

    if (![facebook isSessionValid]) { 
     [facebook authorize:permissions]; 
     [permissions release]; 
    } 

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    if ([defaults objectForKey:@"FBAccessTokenKey"] 
     && [defaults objectForKey:@"FBExpirationDateKey"]) { 
     facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; 
     facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; 
    } 

    //Post to Wall 

    NSString *poopDollas = [[NSString alloc] initWithFormat: 
         @"sometext $%@!",dollas.text]; 

    SBJSON *jsonWriter = [[SBJSON new] autorelease]; 

    // The action links to be shown with the post in the feed 
    NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys: 
                 @"Get Started",@"name",@"http://www.facebook.com/pages/xx/204640386498567",@"link", nil], nil]; 
    NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks]; 
    // Dialog parameters 
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            @"DM", @"name", 
            poopDollas, @"caption", 
            @"sometext", @"description", 
            @"http://www.facebook.com/pages/xx/204640386498567", @"link", 
            @"http://farm8.staticflickr.com/7185/6999841878_e66a8e00fc_t.jpg", @"picture", 
            actionLinksStr, @"actions", 
            nil]; 

    FBDialog *delegate = (FBDialog *)[UIApplication sharedApplication].delegate; 

    [facebook dialog:@"feed" andParams:params andDelegate:(id <FBDialogDelegate>)delegate]; 
} 
+0

一對夫婦的意見:1)請升級您的SBJson的副本。你使用的課程在很多年前已經分成兩個階段;許多*重要的錯誤已經修復。 2)請升級您的代碼以使用ARC。 3)爲了可讀性,請使用字典靜態初始化('@ {@「key」:@「value」}')。 –

回答

0

我拿出

[facebook authorize:permissions]; 
[permissions release]; 

在這第一個IF語句,我的問題似乎解決了..