[英]how to share on facebook within OSX app, without facebook Kit?
I'm looking for way to use Accounts information if they configured in OS X, to post to Facebook, without using facebook kit. 我正在寻找一种方法来使用帐户信息(如果在OS X中对其进行了配置),而无需使用Facebook套件即可发布到Facebook。
I found Social framework but all examples are related to iOS, my App instead should post message from OS X. 我找到了社交框架,但是所有示例都与iOS有关,而我的App应该发布来自OS X的消息。
Using accounts is a good way to go, here's what I did: 使用帐户是一种不错的方式,这是我所做的:
import Accounts
static func post(text:String,completion:(Bool->Void)) {
let accountStore = ACAccountStore()
let accountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierFacebook)
let options : [String:AnyObject] = [
"ACFacebookAppIdKey": "your app key here, from Facebook apps",
"ACFacebookPermissionsKey": ["publish_actions", "manage_pages", "publish_pages"],
"ACFacebookAudienceKey": "ACFacebookAudienceEveryone"
]
accountStore.requestAccessToAccountsWithType(accountType, options: options) {
granted, error in
if granted {
let fbAccounts = accountStore.accountsWithAccountType(accountType)
if fbAccounts != nil {
completion(true)
} else {
print("no accounts")
completion(false)
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.