错误代码 220 - “您的凭据不允许访问此资源"当尝试获得转发时 [英] Error Code 220 - "Your credentials do not allow access to this resource" When tryig to get retweets
本文介绍了错误代码 220 - “您的凭据不允许访问此资源"当尝试获得转发时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试获取 https://api.twitter.com/1.1/statuses/retweets/21947795900469248.json 使用我的授权凭证 (oauth)
,我得到:
When i try to get https://api.twitter.com/1.1/statuses/retweets/21947795900469248.json with my authorized credentials (oauth)
, i'm getting:
{
"errors": [
{
"message": "Your credentials do not allow access to this resource",
"code": 220
}
]
}
错误:任何其他 twit id 都不起作用.这个端点有问题吗?因为直到昨天我才得到真正的回应.有什么变化吗?
error: Any other twit id's not working. Is there a problem with this endpoint? Because i was getting true response until yesterday. Something changed?
推荐答案
我遇到了同样的问题,错误代码为 220.在我的情况下修复是提示用户再次输入其 Twitter 密码.
I experienced same issue with getting error code 220. Fix in my case was to prompt user to enter it's Twitter password again.
检查下面的示例代码:
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"]
parameters:@{@"status": tweetString}];
[request setAccount:account];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if ([responseData isKindOfClass:[NSData class]]) {
NSError *jsonError = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonError];
if (json) {
NSArray *errors = json[@"errors"];
if (errors.count) {
NSUInteger errorCode = [json[@"errors"][0][@"code"] integerValue];
if (errorCode == 220) {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
[accountStore renewCredentialsForAccount:account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error2) {
NSLog(@"Renew result: %ld, error: %@", (long)renewResult, error2);
if (renewResult == ACAccountCredentialRenewResultRenewed) {
[self __makeTweetWithAccounts:@[account] rating:rating review:review];
}
}];
}
}
}
}
NSLog(@"Twitter response data: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
}];
这篇关于错误代码 220 - “您的凭据不允许访问此资源"当尝试获得转发时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文