0
我有一個問題,如果ACAccountStore自動更新Twitter令牌?我需要在我的服務器中使用令牌來進行自動發佈。請分享你的經驗。ACAccountStore Twitter憑據
我有一個問題,如果ACAccountStore自動更新Twitter令牌?我需要在我的服務器中使用令牌來進行自動發佈。請分享你的經驗。ACAccountStore Twitter憑據
如果您發佈使用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];
}];
}