zoukankan      html  css  js  c++  java
  • IOS http 请求

    asihttprequest 为第三方数据请求,一下为get  和post 两种请求。

    Get:

        NSString *loginName=@"Tony";

        NSString *pwd=@"123";

        NSString *postURL=[NSString stringWithFormat:@"http://192.168.2.2:1234/WebServiceDemo.asmx/LoginIn?loginName=%@&pwd=%@",loginName,pwd];

        NSLog(@"发送时请求URL%@",postURL);

        ASIHTTPRequest *request=[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:postURL]];

        [request setRequestMethod:@"GET"];

        [request startSynchronous];

        NSError *error=[request error];

        if(!error)

        {

            NSString *result=[request responseString];

            NSLog(result);

        }

    Post :

    //---------------Http Post-----------------------

        NSString *postUrl=[NSString stringWithFormat:@"http://192.168.2.2:1234/WebServiceDemo.asmx/GetInfo"];

        ASIFormDataRequest *request=[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:postUrl]];

        

        // 设置 post参数

        [request setPostValue:@"1233" forKey:@"LoginName"];

        [request setPostValue:@"dsadasdasd" forKey:@"pwd"];

        [request startSynchronous];

        

        NSString *result=[request responseString];

        NSLog(result);

        [result release];

    //webserice 

    Context.Response.Write("测试通过");

        

  • 相关阅读:
    三次请求(读-改-读)引出nibernate 一级缓存
    算法竞赛入门经典第一、二章摘记
    uva 10905 Children's Game
    uva 11205 The broken pedometer
    uva 10160 Servicing stations
    uva 208 Firetruck
    uva 167 The Sultan's Successors
    zoj 1016 Parencodings
    uva 307 Sticks
    uva 216 Getting in Line
  • 原文地址:https://www.cnblogs.com/pengzhaov/p/3970698.html
Copyright © 2011-2022 走看看