我正在实现一个retweet功能,但是在我的帖子之后,我一直收到一个错误的URL错误。这是我的密码:
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;
}
});
}];有什么想法吗?我有遗漏什么吗?谢谢!
发布于 2013-10-07 18:37:24
是我的错。在创建请求"...%@.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];发布于 2013-10-07 07:42:09
对此
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,你可能会错过一些东西。
发布于 2013-10-09 11:12:00
你应该在你的请求上附加一个帐户。
// 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...
}https://stackoverflow.com/questions/19219260
复制相似问题