OGeek|极客世界-中国程序员成长平台

标题: ios - 添加 curl 参数 CURLOPT_USERPWD IOS [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 18:18
标题: ios - 添加 curl 参数 CURLOPT_USERPWD IOS

这是 PHP 代码:你需要一个带有参数 methode = getAll 的 POST 调用:

$filters = 数组(); $filters['面额'] = 'T%';

    $param = array(
     'type_element' => 'personne_morale',
     'order' => 'denomination',
     'limit' => 2,
     'filtres' => $filters
     );

这是我的 ios 代码,它不工作它给出错误:

NSError *error;

        NSURL *url = [NSURL URLWithString: @"https://www.eden-pme.com/edensoft/edenfiles/edensoft2014/api.php"];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];




        NSURLResponse *response;

        NSString *postString;
        postString = [NSString stringWithFormat"api_public_key:api_private_key,6c8a4cf9044e48e4383b9f6a8f400055:94a337a9dd6fb58f5004f244187d5d39"];


        [request setURL:url];
        [request setHTTPMethod"OST"];
        [request setValue:postString forHTTPHeaderField"Content-Type"];
       // NSURLResponse *response;
        NSData *res = [NSURLConnection  sendSynchronousRequest:request returningResponse:&response error:&error];

        NSArray *jsonArr = [NSJSONSerialization JSONObjectWithData:res options:kNilOptions error:&error];
            NSLog(@"%@",jsonArr);



Best Answer-推荐答案


试试这个,

[request setValue:postString forHTTPHeaderField"Content-Type"];改为

[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];

关于ios - 添加 curl 参数 CURLOPT_USERPWD IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21423078/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4