首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ACAccountStore Twitter凭据

ACAccountStore Twitter凭据
EN

Stack Overflow用户
提问于 2015-02-10 19:34:49
回答 1查看 81关注 0票数 0

我有一个问题,如果ACAccountStore自动更新Twitter令牌?我需要令牌在我的服务器中使用自动投递。请分享你的经验。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-10 20:05:36

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

代码语言:javascript
复制
/**
 *  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];

    }];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28440312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档