gpt4 book ai didi

ios - ACAccountStore Twitter 凭证

转载 作者:行者123 更新时间:2023-11-29 02:18:35 25 4
gpt4 key购买 nike

我有一个问题:ACAccountStore 是否会自动更新 Twitter token ?我需要在我的服务器中使用 token 来自动发布。请分享您的经验。

最佳答案

如果您像这样使用 SLRequest 发帖,您应该没有问题(self.account 是您从 ACAccountStore 检索到的 Twitter ACaccount):

/**
* Post a status update via the account
*
* @param NSString* status status to post
*/
- (void)postViaAccountWithStatus:(NSString *)status
{
// Create the parameters dictionary and the URL (!use HTTPS!)
NSDictionary *parameters = @{@"status": status };
NSURL *URL = [NSURL URLWithString:kTwitterStatusesUpdateEndpoint];

// Create request
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:URL
parameters:parameters];

// Since we are performing a method that requires authorization we can simply
// add the ACAccount to the SLRequest
[request setAccount:self.account];

// Perform request
[request performRequestWithHandler:^(NSData *respData, NSHTTPURLResponse *urlResp, NSError *error)
{
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:respData
options:kNilOptions
error:&error];

// Check for errors in the responseDictionary
if ( urlResp.statusCode == 200 )
[self updateStatusCompleteWithStatus:SHUpdateSuccessful error:error];
else
[self updateStatusCompleteWithStatus:SHUpdateFailed error:error];

}];
}

关于ios - ACAccountStore Twitter 凭证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28440312/

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