zoukankan      html  css  js  c++  java
  • kepware http接口 Objective-C开发

    读取某变量的值(NSURL

    #import <Foundation/Foundation.h>
    
    NSDictionary *headers = @{ @"Connection": @"keep-alive",
                               @"Cache-Control": @"max-age=0",
                               @"Upgrade-Insecure-Requests": @"1",
                               @"User-Agent": @"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
                               @"Accept": @"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                               @"Accept-Encoding": @"gzip, deflate, br",
                               @"Accept-Language": @"zh-CN,zh;q=0.9",
                               @"cache-control": @"no-cache"};
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1:39321/iotgateway/read?ids=Channel1.Device1.tag1,Channel1.Device1.tag2"]
                                                           cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:10.0];
    [request setHTTPMethod:@"GET"];
    [request setAllHTTPHeaderFields:headers];
    
    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                                completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                    if (error) {
                                                        NSLog(@"%@", error);
                                                    } else {
                                                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                        NSLog(@"%@", httpResponse);
                                                    }
                                                }];
    [dataTask resume];

    列出所有变量

    #import <Foundation/Foundation.h>
    
    NSDictionary *headers = @{ @"Connection": @"keep-alive",
                               @"Cache-Control": @"max-age=0",
                               @"Upgrade-Insecure-Requests": @"1",
                               @"User-Agent": @"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
                               @"Accept": @"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                               @"Accept-Encoding": @"gzip, deflate, br",
                               @"Accept-Language": @"zh-CN,zh;q=0.9",
                               @"cache-control": @"no-cache" };
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1:39321/iotgateway/browse"]
                                                           cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:10.0];
    [request setHTTPMethod:@"GET"];
    [request setAllHTTPHeaderFields:headers];
    
    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                                completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                    if (error) {
                                                        NSLog(@"%@", error);
                                                    } else {
                                                        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                        NSLog(@"%@", httpResponse);
                                                    }
                                                }];
    [dataTask resume];
  • 相关阅读:
    HDU 3695 Computer Virus on Planet Pandora (AC自己主动机)
    Crawley Project · Crawley Project
    Ubuntu下deb包的安装方法
    Google Chrome 59 Released – Install on Debian, Ubuntu and Linux Mint
    如何从 WEB 页面中提取信息 | Binuxの杂货铺
    Binuxの杂货铺 Data Highlighter
    pyspider爬京东商品信息案例分享
    Token bucket
    debian8上安装pyspider
    求助下 Ubuntu 15.10(64 位)下安装 pyspider 下的问题
  • 原文地址:https://www.cnblogs.com/dXIOT/p/10626586.html
Copyright © 2011-2022 走看看