i am trying to access facebook in my application to submit scores for my game.. i have registered my application on fb included its api into my xcode project and i am trying to use their sample project to publish the scores using the following code but when i use this code the message is posted on my wall but not all the details are included as used in NSMutabledictionary ..what am i possibly doing wrong??
- (IBAction)publishStream:(id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"a long run", @"name",
@"The Facebook Running app", @"开发者_Python百科caption",
@"it is fun", @"description",
@"http://itsti.me/", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Share what on Facebook", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",
nil];
[_facebook dialog:@"feed"
andParams:params
andDelegate:self];
}
only the SHARE ON FACEBOOK message is posted on my wall along with the name of my application and rest i am not able to figure out how to use... any help will be appreciated??
Here is a modified PublishStream function that works.
- (void)publishStream:(id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
@"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"a long run", @"name",
@"The Facebook Running app", @"caption",
@"it is fun", @"description",
@"http://itsti.me/", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Share on Facebook", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",
[NSString stringWithFormat:@"I scored %d on mycoolgame, Think you can beat me? - http://bit.ly/cJtBkE", totalScore],@"message",
nil];
[_facebook dialog:@"feed"
andParams:params
andDelegate:self];
}
As pointed our by @hemant "stream.publish" is missing. That seems to be all that is missing from the DemoApp included with the Facebook SDK.
精彩评论