与服务器请求返回接收问题

楼下如果是妹子那就 2015-01-14 07:44:20
直接上图,这是server给的接口,同样的接口,Android那边没有问题,我这边用了response header返回的错误是,未传入response_type参数,
这是Android端的代码,
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
httpPost = new HttpPost(
"http://localhost:8080/world/mini/api/httpservice/kiwi/zoo/openApiService/authorize.xhtml");

nvps.clear();
nvps.add(new BasicNameValuePair("response_type", "code"));
nvps.add(new BasicNameValuePair("client_id", appId));
nvps.add(new BasicNameValuePair("type", "implicit"));

httpPost.setEntity(new UrlEncodedFormEntity(nvps));
response = httpclient.execute(httpPost);
code = EntityUtils.toString(response.getEntity());

这是我的代码:

NSDictionary *BasicNameValuePair=@{@"code":@"response_type",
@"10002":@"client_id",
@"implicit":@"type"
};
NSLog(@"BasicNameValuePair:%@",BasicNameValuePair);
NSData *commitBody=[NSJSONSerialization dataWithJSONObject:BasicNameValuePair options:NSJSONWritingPrettyPrinted error:nil];

//创建请求
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *urlString = [NSString stringWithFormat:@"http://192.168.1.101:8080/world/mini/api/httpservice/kiwi/zoo/openApiService/authorize.xhtml"];

NSURL *submitURL = [NSURL URLWithString:urlString];
[request setURL:submitURL];
[request setHTTPMethod:@"POST"];
[request setTimeoutInterval:10];
NSMutableData *commit = [[NSMutableData alloc] init];
[commit appendData:commitBody];
[request setHTTPBody:commit];

我现在请求可以抛过去,这是接收到response header的状态,

诸位帮我看看主要是哪里的问题。
...全文
143 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Proteas 2015-01-19
  • 打赏
  • 举报
回复
找 Server 端的同学一起联调下。 自己分析出错原因的方法:使用 Charles抓包对比,看看 Android 与 iOS 的 Post body 有什么不同。 估计出错的原因是你没有做 URL Encode , Android 那边做了。
伦敦iOS小牛 2015-01-14
  • 打赏
  • 举报
回复
你使用NSURLConnection 吧, 在那几个delegate 方法中设breakpoint 看看返回的是什么。
deveolop 2015-01-14
  • 打赏
  • 举报
回复
LZ 你的问题解决没,我post请求也遇到了一些问题。

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧