我正在我的应用程序中实现 facebook 发布。并添加一些代码以在 facebook 帐户上发布一些内容。我的代码如下。
- (void)publishStory
{
NSLog(@"publish story called .......");
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:self.postParams
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
alertText = [NSString stringWithFormat:
@"error: domain = %@, code = %d",
error.domain, error.code];
} else {
alertText = [NSString stringWithFormat:
@"Posted action, id: %@",
[result objectForKey:@"id"]];
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@"Result"
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}];
}
-(IBAction)cancelButtonAction
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
-(IBAction)shareButtonAction
{
// Add user message parameter if user filled it in
if (![self.postMessageTextView.text isEqualToString:@""]) {
[self.postParams setObject:self.postMessageTextView.text
forKey:@"message"];
}
// Ask for publish_actions permissions in context
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound) {
// No permissions found in session, ask for it
[FBSession.activeSession reauthorizeWithPublishPermissions:
[NSArray arrayWithObjects:@"publish_actions",@"publish_stream", nil]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// If permissions granted, publish the story
NSLog(@"not error");
[self publishStory];
}
}];
} else {
// If permissions present, publish the story
NSLog(@"In else condition");
[self publishStory];
}
}
这是太多的代码,“因为 ios 6 在设置中包含集成的 facebook。” 但我想在 ios 中发布类似 twitter 集成的帖子。我们该怎么做