【发布时间】:2012-10-12 11:39:09
【问题描述】:
使用新的 Facebook SDK 3.1 和 iOS 6,有 2 种(实际上是 3 种)发帖方式。
(似乎新趋势是有更多选择以使其更简单??)天哪!!
这是一个:
SLComposeViewController *fbPost = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbPost addURL:[NSURL URLWithString:href]];
[self presentViewController:fbPost animated:YES completion:nil];
这是使用原生对话框的另一种方式:
[FBNativeDialogs presentShareDialogModallyFrom:self
initialText: nil
image: nil
url: [NSURL URLWithString:href]
handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
}
else
{
switch (result) {
case FBNativeDialogResultSucceeded:
break;
case FBNativeDialogResultCancelled:
break;
case FBNativeDialogResultError:
break;
}
}
}];
我们,开发者,认为这很酷,因为我们为用户提供了一个很好的功能,还因为我们的应用名称出现在帖子中,这可以对应用进行一些推广。
有趣的是,最新的实现不允许指定发布的应用名称,名称出现在“via”之后。
我也尝试过使用 SLRequest:
ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *fbType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
(options)[@"ACFacebookAppIdKey"] = kFacebookAppID;
(options)[@"ACFacebookPermissionsKey"] = @[@"publish_stream"];
(options)[@"ACFacebookAudienceKey"] = ACFacebookAudienceFriends;
[store requestAccessToAccountsWithType:fbType options:options completion:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *fbAccounts = [store accountsWithAccountType:fbType];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
(params)[@"link"] = href;
// (params)[@"picture"] = picture;
// (params)[@"name"] = name;
(params)[@"actions"] = @"{\"name\": \"Go Gabi\", \"link\": \"http://www.gogogabi.com\"}";
//Set twitter API call
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString:@"https://www.facebook.com/dialog/feed"] parameters:params];
//Set account
[postRequest setAccount: [fbAccounts lastObject]];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if(error)
{
NSLog(@"%@", error.description);
}
else
{
NSLog(@"%@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
}
}];
} else {
}
}];
不幸的是,分享这个名字不再那么微不足道了,我想知道为什么以及谁在设计新的实现...... 我希望能得到一些帮助,在此先感谢。
我试着让我的问题变得有趣,因为花时间在如此琐碎的话题上太无聊了......
【问题讨论】:
-
谢谢你的提示,我才发现它......
标签: objective-c ios facebook