微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

聚合数据iOS SDK 全国加油站[实时油价]演示示例

1,将聚合数据SDK(JuheApis.framework)添加到你的程序中来,SDK依赖的包包括


2,在聚合SDK Framework的JHSDKAPIPath.h文件中找到快递查询接口宏,以及字典参数

/*** 全国加油站[实时油价] ***/
/**
 @brief 全国加油站[实时油价] -> 按城市检索加油站
 @param city        string     必填     城市名urlencode utf8;
 @param page        int     非必填     页数,认1
 */
#define kJHAPIS_LIFE_OIL_REGION     @"juhe.apis.oil.region"             //1、按城市检索加油站

/**
 @brief 全国加油站[实时油价] -> 检索周边加油站
 @param lon         double     必填     经纬(如:121.538123)
 @param lat         double     必填     纬度(如:31.677132)
 @param r           int     非必填     搜索范围,单位M,认3000,最大10000
 @param page        int     非必填     页数,认1
 */
#define kJHAPIS_LIFE_OIL_LOCAL      @"juhe.apis.oil.local"              //2、检索周边加油站


3,快递查询接口在程序中调用方法(将ViewController.m改为.mm)

#import "ViewController.h"

#import <JuheApis/JuheAPI.h>
#import <JuheApis/JHOpenidsupplier.h>
#import <JuheApis/JHSDKAPIPath.h>

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view,typically from a nib.
    [[JHOpenidsupplier sharesupplier] registerJuheAPIByOpenId:@"申请到的OpenId“];
    
    UIButton* beginBtn=[UIButton buttonWithType:UIButtonTypeSystem];
    beginBtn.frame=CGRectMake(20,111,280,40);
    [beginBtn setTitle:@"开始" forState:UIControlStatenormal];
    [beginBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStatenormal];
    [beginBtn addTarget:self action:@selector(doTestAction) forControlEvents:UIControlEventTouchUpInside];
    [beginBtn setBackgroundImage:[UIImage imageNamed:@"button5"] forState:UIControlStatenormal];
    [self.view addSubview:beginBtn];
}

- (void)doTestAction
{
    /* 1、按城市检索加油站 */
   [self test :kJHAPIS_LIFE_OIL_REGION           parameters:@{@"city":@"苏州",@"page":@"1" } ] ;


    /* 2、检索周边加油站 */
   [self test :kJHAPIS_LIFE_OIL_LOCAL          parameters:@{@"lon":@"121.538123",@"lat":@"31.677132"  } ] ;

}

- (void)test:(Nsstring *)path  parameters:(NSDictionary *)parameters{
    
    JuheAPI *juheapi = [JuheAPI shareJuheApi];
    [juheapi executeWorkWithAPI:path
                     parameters:parameters
                        success:^(id responSEObject){
                            if ([[parameters objectForKey:@"dtype"] isEqualToString:@"xml"]) {
                                NSLog(@"***xml*** \n %@",responSEObject);
                            }else{
                                int error_code = [[responSEObject objectForKey:@"error_code"] intValue];
                                if (!error_code) {
                                    NSLog(@" %@",responSEObject);
                                }else{
                                    NSLog(@" %@",responSEObject);
                                }
                            }
                            
                        } failure:^(NSError *error) {
                            NSLog(@"error:   %@",error.description);
                        }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // dispose of any resources that can be recreated.
}

@end


4,全国加油站[实时油价]接口返回数据说明以及错误码说明

   4.1、按城市检索加油站

   API : juhe.apis.oil.region (宏kJHAPIS_LIFE_OIL_REGION)

  返回字段 :

@H_337_404@

error_code

@H_337_404@

 

@H_337_404@

int

@H_337_404@

返回码

@H_337_404@

data

@H_337_404@

 

@H_337_404@

dictionary

@H_337_404@

返回结果

@H_337_404@

 

@H_337_404@

area

@H_337_404@

string

@H_337_404@

城市邮编

@H_337_404@

 

@H_337_404@

address

@H_337_404@

string

@H_337_404@

加油站地址

@H_337_404@

 

@H_337_404@

type

@H_337_404@

string

@H_337_404@

加油站类型

@H_337_404@

 

@H_337_404@

exhaust

@H_337_404@

string

@H_337_404@

尾气排放标准

@H_337_404@

 

@H_337_404@

lat

@H_337_404@

double

@H_337_404@

百度地图纬度

@H_337_404@

 

@H_337_404@

price

@H_337_404@

array

@H_337_404@

省控基准油价

@H_337_404@

 

@H_337_404@

fwlsmc

@H_337_404@

string

@H_337_404@

加油卡信息

名称

 

类型

说明

reason

 

string

返回说明

 

name

string

加油站名称

 

areaname

string

城市区域

 

brandname

string

运营商类型

 

discount

string

是否打折加油站

 

position

string

谷歌地图坐标

 

lon

double

百度地图经度

 

gastprice

array

加油站油价



   4.2、检索周边加油站
   API : juhe.apis.oil.local (宏kJHAPIS_LIFE_OIL_LOCAL )

@H_337_404@

error_code

@H_337_404@

 

@H_337_404@

int

@H_337_404@

返回码

@H_337_404@

data

@H_337_404@

 

@H_337_404@

dictionary

@H_337_404@

返回结果

@H_337_404@

 

@H_337_404@

area

@H_337_404@

string

@H_337_404@

城市邮编

@H_337_404@

 

@H_337_404@

address

@H_337_404@

string

@H_337_404@

加油站地址

@H_337_404@

 

@H_337_404@

type

@H_337_404@

string

@H_337_404@

加油站类型

@H_337_404@

 

@H_337_404@

exhaust

@H_337_404@

string

@H_337_404@

尾气排放标准

@H_337_404@

 

@H_337_404@

lat

@H_337_404@

double

@H_337_404@

百度地图纬度

@H_337_404@

 

@H_337_404@

pricelon

@H_337_404@

string

@H_337_404@

省控基准油价

@H_337_404@

 

@H_337_404@

fwlsmc

@H_337_404@

string

@H_337_404@

加油卡信息

名称

 

类型

说明

reason

 

string

返回说明

 

name

string

加油站名称

 

areaname

string

城市区域

 

brandname

string

运营商类型

 

discount

string

是否打折加油站

 

position

string

谷歌地图坐标

 

lon

double

百度地图经度

 

gastprice

string

加油站油价

 

distance

string

与坐标的距离,单位M 



  4.3. 全国加油站[实时油价] 错误码 

 

错误

 

200701

城市名不能为空

 

200702

错误的经纬度

 

200703

无结果了

 

200705

无结果了


5,更多聚合数据SDK接口,访问这里: http://www.juhe.cn/juhesdk/idocs

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐