有什么方法可以在 ios 中不显示共享对话框的情况下在 Facebook 上共享
is there any way to share on facebook without showing the share dialog box in ios
这是我的代码,但变得无效 publish_streem
。 ios?
有什么方法可以在不显示分享对话框的情况下在 Facebook 上分享吗?
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
//ACAccount *facebookAccount;
// Specify App ID and permissions
NSDictionary *options = @{ACFacebookAppIdKey:@"565048226932112",ACFacebookPermissionsKey:@[@"publish_stream", @"publish_actions"],ACFacebookAudienceKey:ACFacebookAudienceFriends};
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
// NSLog(@"Error :%@",error);
}
}];
使用 Facebook 图谱 API
https://developers.facebook.com/docs/graph-api/reference/v2.2/post
参考:https://developers.facebook.com/docs/ios/share
// 注意:预填与 Facebook 帖子相关的字段,
// 除非用户在您应用的工作流程中较早地手动生成了内容,
// 可以违反平台政策:https://developers.facebook.com/policy
// 把对话框参数放在一起
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
// Make the request
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog(@"result: %@", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", error.description);
}
}];
使用 API 调用
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
// Make the request
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog(@"result: %@", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", error.description);
}
}];
这是我的代码,但变得无效 publish_streem
。 ios?
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
//ACAccount *facebookAccount;
// Specify App ID and permissions
NSDictionary *options = @{ACFacebookAppIdKey:@"565048226932112",ACFacebookPermissionsKey:@[@"publish_stream", @"publish_actions"],ACFacebookAudienceKey:ACFacebookAudienceFriends};
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
// NSLog(@"Error :%@",error);
}
}];
使用 Facebook 图谱 API
https://developers.facebook.com/docs/graph-api/reference/v2.2/post
参考:https://developers.facebook.com/docs/ios/share
// 注意:预填与 Facebook 帖子相关的字段, // 除非用户在您应用的工作流程中较早地手动生成了内容, // 可以违反平台政策:https://developers.facebook.com/policy
// 把对话框参数放在一起
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
// Make the request
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog(@"result: %@", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", error.description);
}
}];
使用 API 调用
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
// Make the request
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog(@"result: %@", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", error.description);
}
}];