2012-04-16 63 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