在iPhone SDK上进行带参数的GET请求吗?
我正在做一个检索用户信息的应用程序,它使用 GET 请求来实现这一点,但我不知道如何制作一个。已经使用此代码尝试了 ASIHTTPRequest:
NSURL *url = [NSURL URLWithString:@"http://forrst.com/api/v2/users/info"];
// Now, set up the post data:
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:@"1" forKey:@"id"];
[request setRequestMethod:@"GET"];
// Initiate the WebService request
[request setDelegate:self];
[request startAsynchronous];
但我从 forrst 得到了此响应:
2011-06-05 16:59:32.189 Forrsty[4335:207] {"resp":{"error":"you must pass either id or username"},"stat":"fail","in":0.0557,"authed":false,"authed_as":false,"env":"prod"}
我知道我没有正确执行 GET 请求,那么我将如何做到这一点?谢谢 :)
I'm doing an app which retrieves user info, and it does that using a GET request, but I don't know how could I make one. Already tried ASIHTTPRequest with this code:
NSURL *url = [NSURL URLWithString:@"http://forrst.com/api/v2/users/info"];
// Now, set up the post data:
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:@"1" forKey:@"id"];
[request setRequestMethod:@"GET"];
// Initiate the WebService request
[request setDelegate:self];
[request startAsynchronous];
But I get this response from forrst:
2011-06-05 16:59:32.189 Forrsty[4335:207] {"resp":{"error":"you must pass either id or username"},"stat":"fail","in":0.0557,"authed":false,"authed_as":false,"env":"prod"}
Which I understand I'm not doing the GET request ok, so how I would do it? Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
获取参数?
那么为什么不尝试“http://forrst.com/api/v2/users/info?id=1”呢?
顺便说一下,看看这个库: http://allseeing-i.com/ASIHTTPRequest/
祝你好运!
A Get Parameter ?
So why don't you try "http://forrst.com/api/v2/users/info?id=1" ?
By the way, take a look at this librayry : http://allseeing-i.com/ASIHTTPRequest/
Good luck !