2012-04-16 50 views
0

除了來自用戶的小消息blurb('消息'參數)之外,每個參數都得到正確發佈。該帖子的這部分怎麼不顯示在臉書上?我是否設置了錯誤的參數? 請看看這個圖片看到我在談論該職位的一部分: https://skitch.com/hahmadi82/8uecw/brenton-joyninFacebook IOS SDK requestWithGraph not posting消息

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
                 [NSString stringWithFormat:@"%@ has invited you (%@) to enjoy an offer at %@ on %@", [nameArray objectAtIndex:0], [facebookNameArray objectAtIndex:i], spotString, timeChosenString], @"name", 
                 domain, @"link", 
                 [NSString stringWithFormat:@"%@ (%@)", offerString, peopleString], @"caption", 
                 @"Going out? Use JoynIn to grab amazing offers from local bars, clubs, and restaurants. All you need to bring is friends!", @"description", 
                 titleChosen.text, @"message",    
                 nil]; 
         [facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed/",[facebookUIDArray objectAtIndex:i]] andParams:params andHttpMethod:@"POST" andDelegate:self]; 

回答

0

首先,「怎麼來」是孩子們說些什麼。 LOL對不起。其次,這是發佈到其他用戶的Feed。所以你應該檢查他們的牆上的帖子,而不是你的牆。

我相信你必須包括說明。這是我們使用的代碼。看起來像你的代碼應該工作。您還應該檢查以確保您的%@格式化程序中有適當的Facebook ID。

NSString *message = NSLocalizedString(@"FACEBOOK_INVITE_MESSAGE", nil); 
NSString *link = @"http://www.facebook.com/trivialapp"; 
NSString *description = NSLocalizedString(@"FACEBOOK_INVITE_DESCRIPTION", nil); 
NSString *picture = @"http://trivi.al/Content/images/icon72.png"; 
NSMutableDictionary *tParams = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           message,  @"message", 
           link,  @"link", 
           description, @"description", 
           picture,  @"picture", nil]; 

[facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed", [playerDict objectForKey:@"id"]] 
         andParams:tParams 
        andHttpMethod:@"POST" 
        andDelegate:self]; 
0

是你的Facebook sessionValid?要求與if語句:

 if (facebook isSessionValid) { 
NSLog (@"Working fine..."); // it might also be better to place the post method in here and put an else statement to open a alert where it says error or something like that 
} 

如果不是....檢查方法,如

handleOpenURL和fbDidLogin

登錄那裏,看看是否叫....如果不是我有一個非常相似問題...生病引導您完成

所以我的問題是我應該宣佈在App代表Facebook的變量...看這個..這是看你應該做的:

 - (void)viewDidLoad 
    { 
fbAppDelegate = (NerdfeedAppDelegate *)[[UIApplication sharedApplication] delegate]; 
[[fbAppDelegate facebook] authorize:nil];// or wherever you wanna put it... 
[super viewDidLoad]; 
// Do any additional setup after loading the view from its nib. 
    } 

    -(IBAction)post { 

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
                [NSString stringWithFormat:@"%@ has invited you (%@) to enjoy an offer at %@ on %@", [nameArray objectAtIndex:0], [facebookNameArray objectAtIndex:i], spotString, timeChosenString], @"name", 
                domain, @"link", 
                [NSString stringWithFormat:@"%@ (%@)", offerString, peopleString], @"caption", 
                @"Going out? Use JoynIn to grab amazing offers from local bars, clubs, and restaurants. All you need to bring is friends!", @"description", 
                titleChosen.text, @"message",    
                nil]; 
        [fbAppDelegate.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed/",[facebookUIDArray objectAtIndex:i]] andParams:params andHttpMethod:@"POST" andDelegate:self]; 



    } 

應用Delegate.h:

@interface AppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate, FBDialogDelegate, FBLoginDialogDelegate, FBRequestDelegate> 

    { 

    Facebook *facebook; 

    } 


    @property (strong, nonatomic) UIWindow *window; 
    @property (strong, nonatomic) Facebook *facebook; 

應用Delegate.m:

 static NSString *kAppID; 
     - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { 
return [facebook handleOpenURL:url]; 
    } 

    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 
return [facebook handleOpenURL:url]; 
} 
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    kAppID = [[NSString alloc] initWithString:@"//app id"]; 
    // .... 
    facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:(id)self.viewController]; 
     [facebook setSessionDelegate:self]; 
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
     if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { 
     facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"]; 
     facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"]; 
    } 

return YES; 
    } 


- (void)fbDidLogin { 

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"]; 
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"]; 
[defaults synchronize];  
     } 

    -(void)fbDidLogout { 


// Remove saved authorization information if it exists 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 

if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { 
    [defaults removeObjectForKey:@"FBAccessTokenKey"]; 
    [defaults removeObjectForKey:@"FBExpirationDateKey"]; 
    [defaults synchronize]; 
    } 
    } 
+0

在我的崗位每個參數除消息正常工作。所以問題不在於它沒有發佈,而是在發佈一切,但是來自用戶的小消息評論。我的猜測是我沒有正確設置參數? – 2012-04-16 19:34:14

0

如果你的意思後對話其實那不是可能發佈的消息,我面臨同樣的問題,我發現這在Facebook文檔

此字段是爲用戶表達自己的意圖。預填充 此字段侵蝕了用戶語音的真實性。

+0

我不知道爲什麼是這樣的話......與PHP Facebook的庫我可以使用我們網站上的所有參數發佈這些消息。這是不讓我做同樣的ios sdk。 – 2012-04-16 19:36:09