gpt4 book ai didi

ios - 无法快速获取推特用户详细信息

转载 作者:行者123 更新时间:2023-11-28 08:55:09 26 4
gpt4 key购买 nike

我正在尝试使用此代码加载 Twitter 用户详细信息

@IBAction func twitterLogin(sender: UIButton) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) {

let accountType = self.accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)

accountStore.requestAccessToAccountsWithType(accountType, options: nil, completion: { (granted : Bool, error : NSError?) -> Void in
if error != nil {
print("Error in getting permission : \(error)")
} else {
if granted {
let accounts : NSArray = self.accountStore.accountsWithAccountType(accountType)
if accounts.count > 0 {
self.twitterAccount = accounts.lastObject as? ACAccount

let url = NSURL(string: "https://api.twitter.com/1.1/users/show.json")

let parameters : NSDictionary = ["fields": "user_id,screen_name"]

let twitterRequest : SLRequest = SLRequest(forServiceType: SLServiceTypeFacebook, requestMethod: SLRequestMethod.GET, URL: url, parameters: parameters as [NSObject : AnyObject])
twitterRequest.account = self.facebookAccount
twitterRequest.performRequestWithHandler({ (responseData : NSData?, urlResponse : NSHTTPURLResponse?, error : NSError?) -> Void in

if error != nil {
print("Error : \(error)")
} else {
// print("data : \(responseData)")
if let response = responseData {
var dict = NSDictionary()
do {
dict = try! NSJSONSerialization.JSONObjectWithData(response, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
} catch let error as NSError {
print("Error : \(error)")
}
print(dict)
}
}
})
}
} else {
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.showAlert(nil, message: "Permission not granted")
})
}
}
})
} else {
self.askForSettingsChange("No Twitter Account", message: "There are no Twitter accounts configured. You can add or create Twitter account in Settings")
}
}

输出

{
errors = (
{
code = 215;
message = "Bad Authentication data.";
}
);
}

得到了很多例子,却得不到合适的解决方案。
我认为这可能是 api 调用中的问题或者可能是参数。
尝试改正未成功

最佳答案

Fabric 是 sdk,它通过访客或用户登录提供 Twitter 登录和简单的身份验证。

Twitter login using Fabric

用 Swift 编写的示例代码 https://docs.fabric.io/ios/twitter/index.html

如果您想对 API 使用原始 REST 调用,请遵循开发人员文档中的 OAuth 详细信息

https://dev.twitter.com/oauth

关于ios - 无法快速获取推特用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33260578/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com