MGTwitterEngine - isUser:receivingUpdatesFor: 总是返回 HTTP 错误 400?
我在实现 MGTwitterEngine 的 isUser:receivingUpdatesFor: 方法以检查用户是否在 Twitter 上关注另一个用户时遇到一些问题。这是我的代码:
//Here is how I call the method (isRequestIdentifier is an NSString declare in the .h)
isRequestIdentifier = [[twitterEngine isUser:user1 receivingUpdatesFor:user2] retain];
NSLog(@"user1 : %@ - user2 : %@", user1, user2);
NSLog(@"isRequestIdentifier : %@",isRequestIdentifier);
#pragma mark TwitterEngineDelegate
- (void) requestSucceeded: (NSString *) requestIdentifier {
if ([requestIdentifier isEqualToString:isRequestIdentifier]) {
NSLog(@"Request isRequestIdentifier %@ succeeded", requestIdentifier);
}
}
- (void) requestFailed: (NSString *) requestIdentifier withError: (NSError *) error {
if ([requestIdentifier isEqualToString:isRequestIdentifier]) {
NSLog(@"Request isRequestIdentifier : %@ failed with error: %@", requestIdentifier, error);
}
}
它似乎可以工作,但即使我确定 user1 正在关注 user2,我的请求也总是失败,这是日志消息:
Request isRequestIdentifier : E8284E63-A5B0-4C18-A3DB-B4F0A5E6048E failed with error :错误域=HTTP代码=400“操作无法完成。(HTTP错误400。)”
知道我做错了什么吗?
感谢您的帮助。
I have some problem to implement the method isUser:receivingUpdatesFor: from the MGTwitterEngine in order to check if a user is following another user on Twitter. Here is my code :
//Here is how I call the method (isRequestIdentifier is an NSString declare in the .h)
isRequestIdentifier = [[twitterEngine isUser:user1 receivingUpdatesFor:user2] retain];
NSLog(@"user1 : %@ - user2 : %@", user1, user2);
NSLog(@"isRequestIdentifier : %@",isRequestIdentifier);
#pragma mark TwitterEngineDelegate
- (void) requestSucceeded: (NSString *) requestIdentifier {
if ([requestIdentifier isEqualToString:isRequestIdentifier]) {
NSLog(@"Request isRequestIdentifier %@ succeeded", requestIdentifier);
}
}
- (void) requestFailed: (NSString *) requestIdentifier withError: (NSError *) error {
if ([requestIdentifier isEqualToString:isRequestIdentifier]) {
NSLog(@"Request isRequestIdentifier : %@ failed with error: %@", requestIdentifier, error);
}
}
It seems to work but I always have failed request even when I'm sure that the user1 is following the user2, here is the log message:
Request isRequestIdentifier : E8284E63-A5B0-4C18-A3DB-B4F0A5E6048E failed with error: Error Domain=HTTP Code=400 "The operation couldn’t be completed. (HTTP error 400.)"
Any idea on what I'm doing wrong?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想出来了:)!
转到 MGTwitterEngine.m 并查找以下声明:
您会发现以下代码:
这会导致问题,因为“next”函数采用path 不会将参数写入 url,这就是我们收到 400 Bad Request 错误的原因。
我所做的“快速而肮脏”的修复是注释所有这些行并添加:
工作完美!
I figured it out :)!
Go to MGTwitterEngine.m and look for the declaration of:
You will find this code:
That causes the problem, becasue the 'next' function that takes the path does NOT writes the params into the url, and that's why we were getting that 400 Bad Request error.
The 'quick and dirty' fix I did is to comment all those lines and add:
Works flawless!