我有一个 Facebook 页面,我想在该页面上分享一些文本,就像我们在应用程序的“我/提要”上分享的状态一样。
请有人建议我应该怎么做?
我有一个 Facebook 页面,我想在该页面上分享一些文本,就像我们在应用程序的“我/提要”上分享的状态一样。
请有人建议我应该怎么做?
这里有一些代码片段可以帮助您,但您也应该看看 Facebook 开发人员示例,这些示例非常好。
// To log in to Facebook with permission to post...
m_Facebook = [[Facebook alloc] initWithAppId:YOUR_FACEBOOK_APPID
andDelegate:self];
m_FacebookPermissions = [[NSArray
arrayWithObjects:/*@"read_stream",*/ @"publish_stream", nil] retain];
[m_Facebook authorize:m_FacebookPermissions];
在 fbDidLogin 回调告诉您您已登录之后,在其他一些方法中:
// After successful login…
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
WHAT_YOU_WANT_TO_SAY, @"message",
nil];
[m_Facebook requestWithGraphPath:@"/me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
对于 iOS 6.0,您可以执行以下操作:
NSString *text1 = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Check out this nice'... ", @""), self.title];
NSString *text2 = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"in", @""), self.restaurant.title];
NSString *text3 = NSLocalizedString(@"Sent from FoodRock Menus App", @"");
NSURL *appURL = [NSURL URLWithString:@"http://testappstorelink.com"];
NSArray *activityItems = [NSArray arrayWithObjects:text1, text2, text3, appURL, photo, nil];
UIActivityViewController *actVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:nil];
actVC.excludedActivityTypes = [NSArray arrayWithObjects:UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard,
UIActivityTypePrint, UIActivityTypeSaveToCameraRoll, nil];
actVC.completionHandler = ^(NSString *activityType, BOOL completed){
DLog(@"ACTIVITYTYPE: %@ FINISHED: %@", activityType, completed ? @"YES" : @"NO");
if (completed) {
NSString *socialString = @"";
if ([activityType containsSubstring:@"PostToTwitter"]) {
socialString = @"Twitter";
} else if ([activityType containsSubstring:@"PostToFacebook"]) {
socialString = @"Facebook";
} else if ([activityType containsSubstring:@"Message"]) {
socialString = @"Message";
} else if ([activityType containsSubstring:@"Mail"]) {
socialString = @"Mail";
}
[[FRNWAchievementsController controller] reportSocialShareEvent:socialString menuItem:self];
}
};
return actVC;