iphone : FBConnect Auto post to user wall

2019-03-30 09:10发布

问题:

i want to auto post to a user wall from my iphone applications ( without that "publish" "skip" dialog box ). how i can do that ?

回答1:

the following should be called in the class that implements FBSessionDelegate and FBRequestDelegate:

Facebook *_facebook = [[Facebook alloc] initWithAppId:kAppId];
NSArray *_permissions =  [[NSArray arrayWithObjects:
                           @"read_stream", @"offline_access",nil] retain];
[_facebook authorize:_permissions delegate:self];

And that is the call for fb post (should be used in the same class):

NSString *message = @"This is the message I want to post";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               message, @"message",
                               nil];

[_facebook requestWithMethodName:@"stream.publish"
                       andParams:params
                   andHttpMethod:@"POST"
                     andDelegate:self];

If you want to post a message on the wall of other user you should include "uid" parameter in your params dictionary. Please consult http://developers.facebook.com/docs/reference/rest/stream.publish/

P.S. There are all the necessary examples in the iPhone Facebook connect SDK sample code, so please do not afraid to investigate just a little bit ;)