我有一个问题,如果ACAccountStore自动更新Twitter令牌?我需要令牌在我的服务器中使用自动投递。请分享你的经验。
发布于 2015-02-10 20:05:36
如果您这样使用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];
}];
}https://stackoverflow.com/questions/28440312
复制相似问题