gpt4 book ai didi

ios - 如何将身份验证 token 从 Parse SDK 传递到 Fabric TwitterKit?

转载 作者:行者123 更新时间:2023-12-01 18:50:47 25 4
gpt4 key购买 nike

我使用 +[PFTwitterUtils loginWithBlock:] 登录我的 Twitter 用户Parse SDK 中的方法。要获取用户个人资料图片,我第二次使用 -[Twitter logInWithCompletion:] 登录Fabric TwitterKit 中的方法。有没有办法将身份验证 token 从 Parse SDK 传递到 TwitterKit 和 只登录一次 ?

有一种方法可以使用 PF_Twitter 从 Parse 导出身份验证 token 和身份验证 token secret 。 Parse SDK 中的类。看起来应该可以使用 -[TWTRSession initWithSessionDictionary:] 创建 TwitterKit session 。 , 但是 Twitter docs对字典格式一无所知,我无法让它工作。

最佳答案

解析

当用户使用 Parse 的 TwitterUtils 登录时,你会得到这个名为 twitter 的方法。 .现在我正在使用 Swift,所以使用 PFTwitterUtils.twitter()您将获得所需的所有数据。我想应该是[PFTwitterUtils twitter];在 Objective-C 中。

类(class)是PF_Twitter在解析上。

Fabric TwitterKit

获得该对象后,您将可以访问 authTokenauthTokenSecret对于当前用户。
然后你必须使用 TwitterKit 中的这个方法(注意:这将在 future 被弃用,查看底部的 更新 ):

objective-C :
[Twitter sharedInstance]logInWithExistingAuthToken:authTokenSecret:completion:
迅速:

Twitter.sharedInstance().logInWithExistingAuthToken(authToken, authTokenSecret: authTokenSecret, completion: { (session, error) -> Void in
})

如果一切顺利,这将返回当前 session 。

文档:

解析:

https://parse.com/docs/ios/api/Classes/PFTwitterUtils.html#//api/name/twitter

PF_Twitter - https://parse.com/docs/ios/api/Classes/PF_Twitter.html

织物:

https://docs.fabric.io/appledocs/Twitter/Classes/Twitter.html#//api/name/logInWithExistingAuthToken:authTokenSecret:completion :

更新 :

我刚刚注意到 logInWithExistingAuthToken将被弃用。所以最好的方法是使用 TWTRSessionStoresaveSessionWithAuthToken方法:
Twitter.sharedInstance().sessionStore.saveSessionWithAuthToken(authToken, authTokenSecret: authTokenSecret, completion: { (session, error) -> Void in

})

关于ios - 如何将身份验证 token 从 Parse SDK 传递到 Fabric TwitterKit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31069623/

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