开发者

Facebook iPhone SDK - automatically PublishSteam (bypass Post to wall dialog)

开发者 https://www.devze.com 2023-04-04 01:56 出处:网络
Trying to implement facebook wall post on the iphone app I\'m working on. How can I bypass the \"Post to Your Wall\" dialog box and just submit straight?

Trying to implement facebook wall post on the iphone app I'm working on.

How can I bypass the "Post to Your Wall" dialog box and just submit straight?

Basically I'm just trying to post a url and I don't really want to allow people to see that "Write something" textbox.

Here is the code that I have so far (from the sample app).

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 Face开发者_如何学Pythonbook",  @"user_message_prompt",
                             actionLinksStr, @"action_links",
                             attachmentStr, @"attachment",
                             nil];


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

Thank you,

Tee


Just use one of the - (FBRequest*)requestWith... instance methods of the Facebook class.

Simple wall post using the old REST API:

NSString *facebookStatusMessage = @"facebookStatusMessage";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                facebookStatusMessage, @"status",
                                nil];

FBRequest *request = [_facebook requestWithMethodName:@"status.set" andParams:params andHttpMethod:@"POST" andDelegate:self];

It's better to use the Facebook Graph API with - (FBRequest*)requestWithGraphPath: as the REST API will get deprecated.

Then also implement some of the FBRequestDelegate protocol:

- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
}

- (void)request:(FBRequest *)request didLoad:(id)result {
    // result may be a dictionary, an array, a string, or a number, 
    // depending on the format of the API response
}
0

精彩评论

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