我正在实施转发功能,但在POST后我一直收到错误的网址错误。 这是我的代码:
SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/retweet/%@.json"] parameters:[NSDictionary dictionaryWithObject:tweetId forKey:@"id"]];
[twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([urlResponse statusCode] == 429) {
NSLog(@"Rate limit reached");
return;
}
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
return;
}
});
}];
有什么想法吗?我错过了什么吗?谢谢!
答案 0 :(得分:1)
我的坏。我在创建请求时忘了传递字符串“...%@。json”。
即
SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/statuses/retweet/%@.json",@"490794578250059776"]] parameters:nil];
答案 1 :(得分:0)
这是
的内容
SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/retweet/%@.json"] parameters [NSDictionary dictionaryWithObject:tweetId forKey:@"id"]];
试试这个
SLRequest *twitterRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/retweet/%@.json"] parameters:[NSDictionary dictionaryWithObject:tweetId forKey:@"status"]];
有一件事你不能一次又一次地重新发布同一个消息,它会被视为垃圾邮件 并且看到这个link可能你可能会错过一些东西
答案 2 :(得分:0)
您应该在您的请求中附加一个帐户。
// create a request
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
URL:url
parameters:@{@"screen_name":@"nst021"}];
// attach an account to the request
NSArray *twitterAccounts = [accountStore accountsWithAccountType:twitterAccountType];
[request setAccount:[twitterAccounts lastObject]];
// execute the request
[request performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse,
NSError *error) {
// caution, you're on an arbitrary queue here...
}