[英]is there any way to share on facebook without showing the share dialog box in ios
here is my code but am getting invalid publish_streem
. 这是我的代码,但是变得无效
publish_streem
。 Is there any way to share on facebook without showing the share dialog box in ios? 有没有办法在Facebook上共享而不在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);
}
}];
Use Facebook Graph API 使用Facebook Graph API
https://developers.facebook.com/docs/graph-api/reference/v2.2/post https://developers.facebook.com/docs/graph-api/reference/v2.2/post
Reference : https://developers.facebook.com/docs/ios/share 参考: https : //developers.facebook.com/docs/ios/share
// NOTE: pre-filling fields associated with Facebook posts, // unless the user manually generated the content earlier in the workflow of your app, // can be against the Platform policies: https://developers.facebook.com/policy //注意:预先填写与Facebook帖子相关的字段,//除非用户在应用程序的工作流程中较早地手动生成了内容,否则//可能违反平台政策: https : //developers.facebook.com/policy
// Put together the dialog parameters //组合对话框参数
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);
}
}];
Using API calls 使用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);
}
}];
Reference :- https://developers.facebook.com/docs/ios/share 参考: -https : //developers.facebook.com/docs/ios/share
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.