开发者

Facebook iOS SDK Dialog parameters

This is probably a n00b question, but nontheless... I have a bit of a problem using the Facebook SDK in my iPad app: when I display a dialog using [facebook dialog:@"feed" andDelegate:self]; I don't see any way I can change the title, the content or the URL of what I want to share.

In their Demo App, Facebook has the following code:

- (IBAction)publishStream:(id)sender {

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

  NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary 
  dictionaryWithObjectsAndKeys: @"Alw开发者_如何学Cays 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",
                                 nil];


  [_facebook dialog:@"feed"
          andParams:params
        andDelegate:self];

}

However, when I press the publishStream button, none of those strings shows on the dialog! :S

Is there something I'm not doing right? all I changed in that Demo App was the Facebook kAppId and the URL Scheme.


I realized this is already answered, but I found this to be the correct answer. It follows what FB has here. The image and/or link actually shows up in the dialog. stream.publish didn't make that change for me. Also, the dialog page says that the stream.publish is old.

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
                               @"http://fbrell.com/f8.jpg", @"picture",
                               @"Facebook Dialogs", @"name",
                               @"Reference Documentation", @"caption",
                               @"Dialogs provide a simple, consistent interface for apps to interact with users.", @"description",
                               @"Facebook Dialogs are so easy!",  @"message",
                               nil];


[_facebook dialog:@"feed"
        andParams:params
      andDelegate:self];


I had the same problem. This is the solution I found: change your code in this way:

[_facebook dialog:@"stream.publish"
         andParams:params
         andDelegate:self];

use stream.publish and not feed.


Hmm.. I haven't worked with the sample app, but I would think that you would need to do a POST if you want to post something to the wall. Check out this question and my answer here: Post to user's Facebook wall with iPhone using latest FBConnect SDK

To summarize, here is the method I used:

- (void)requestWithGraphPath:(NSString *)graphPath
                   andParams:(NSMutableDictionary *)params
               andHttpMethod:(NSString *)httpMethod
                 andDelegate:(id <FBRequestDelegate>)delegate;

like this:

[_facebook requestWithGraphPath:@"[user_id]/feed" 
                          andParams:[NSMutableDictionary dictionaryWithObject:@"test wall post" forKey:@"message"]
                      andHttpMethod:@"POST"
                        andDelegate:self];

to post a comment to [user_id]'s wall.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜