在ios中发出curlopt_userpwd发布请求

时间:2014-01-28 10:39:51

标签: ios

这是php代码:
  methode = getAll         filters = array();

    filters['denomination']  = 'T%';

    param = array(
     'type_element' => 'personne_morale',
     'order' => 'denomination',
     'limit' => 2,
     'filtres' => $filters
     );
    filters is the filters (like the first letter of the name of the company, example here is 'T')
    you don't need limit = 2

我的代码无法正常运行它会出错:

    NSURL *url = [[NSURL alloc]initWithString:[NSString stringWithFormat:@"https://www.eden-pme.com/edensoft/edenfiles/edensoft2014/api.php?methode=getAll"]];
NSString *postString = [NSString stringWithFormat:@"94a337a9dd6fb58f5004f244187d5d39:6c8a4cf9044e48e4383b9f6a8f400055"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url                                                    cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response;
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *str = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

0 个答案:

没有答案