美文网首页
手机号查询POST请求

手机号查询POST请求

作者: 法库德 | 来源:发表于2017-09-19 08:32 被阅读0次

{

UITextField *fi;

UITextView *vi;

NSMutableData *data1;

}

#define  SJH @"http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo"

{

[super viewDidLoad];

UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(20, 40, 100, 44)];

lab.text=@"手机号";

[self.view addSubview:lab];

fi=[[UITextField alloc]initWithFrame:CGRectMake(60, 40, 150, 44)];

[self.view addSubview:fi];

vi=[[UITextView alloc]initWithFrame:CGRectMake(30, 150, 300, 200)];

vi.backgroundColor=[UIColor redColor];

[self.view addSubview:vi];

//设置按钮

UIButton *bu=[[UIButton alloc]initWithFrame:CGRectMake(50, 90, 100, 44)];

bu.backgroundColor=[UIColor redColor];

[bu setTitle:@"查询" forState:UIControlStateNormal];

[bu addTarget:self action:@selector(fan) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:bu];

}

-(void)fan

{

//设置接受

NSURL *url=[NSURL URLWithString:SJH];

//

NSMutableURLRequest *mu=[[NSMutableURLRequest alloc]initWithURL:url];

//设置请求方式

[mu setHTTPMethod:@"POST"];

//设置传递参数

NSString *stee=[NSString stringWithFormat:@"mobileCode=%@&userID=",fi.text];

//格式转换

NSData *da=[stee dataUsingEncoding:NSUTF8StringEncoding];

//设置需要传递参数

[mu setHTTPBody:da];

//

//

//    //

//    NSData *da2=[NSURLConnection sendSynchronousRequest:mu returningResponse:nil error:nil];

//

//    vi.text=[[[NSString alloc]initWithData:da2 encoding:NSUTF8StringEncoding]substringWithRange:NSMakeRange(78, 26)];

//设置代理

[NSURLConnection connectionWithRequest:mu delegate:self];

}

//请求服务器成功后自动回调 执行一次

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;

{

//初始化

data1=[[NSMutableData alloc]init];

}

//成功读取服务器端数据后自动回调 执行多次

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;

{

//拼接数据

[data1 appendData:data];

}

//请求结束后自动回调

- (void)connectionDidFinishLoading:(NSURLConnection *)connection;

{

//展示转换格式

vi.text=[[NSString alloc]initWithData:data1 encoding:NSUTF8StringEncoding];

}

相关文章

  • 手机号查询POST请求

    { UITextField *fi; UITextView *vi; NSMutableData *data1; ...

  • Fetch/axios

    GET: POST请求 DELETE: AxiosDELETE:删除 POST 增加 GET: 查询

  • 接口文档格式

    1、注册 提供手机号和密码的登录方式。 请求说明 请求方式:POST 请求URL :login 参数 返回结果...

  • ajax首次请求后台参数为空

    查询请求type为GET,千万不要误用POST,谨记!

  • HttpUrlConnection

    get请求 post请求 3.post封装 使用方法:先上业务场景,是一个用户的登录操作,收集手机号码和密码 后进...

  • day46-cookie及session

    1请求方式 请求方式有get和post两种方式;数据查询用get请求数据操作(增、删及改操作)用post请求 1....

  • Elasticsearch基本操作-搜索

    一、返回结构 二、查询方式 1、GET查询方式 2、POST 查询方式(请求体查询方式) query内部简单包含关...

  • 2019-06-28

    ES 正则 查询手机号为移动运营商DSL(性能巨慢): POST tbcrm_*/memberInfo/_upda...

  • python请求模块

    爬虫请求模块 urllib.request中的get与post请求 get请求,查询参数在url地址中显示head...

  • Vue基础-day-04(接口调用方式,Promise,Fetc

    1 Restful形式的URL http请求方式GET 查询POST 添加PUT 修改DELETE ...

网友评论

      本文标题:手机号查询POST请求

      本文链接:https://www.haomeiwen.com/subject/uqaisxtx.html