1,將聚合數據SDK(JuheApis.framework)添加到你的程序中來,SDK依賴的包包括:
2,在聚合SDK Framework的JHSDKAPIPath.h文件中找到快遞查詢接口宏,以及字典參數
/**
@brief 車輛違章查詢--1、獲取支持城市接口
*/
#define kJHAPIS_LIFE_WZ_CITYS @"juhe.apis.wz.citys" //1、獲取支持城市接口
/**
@brief 車輛違章查詢--2、請求違章查詢接口
*/
#define kJHAPIS_LIFE_WZ_QUERY @"juhe.apis.wz.query" //2、請求違章查詢接口
/**
@brief 車輛違章查詢--3、車輛(號牌)種類編號查詢接口
*/
#define kJHAPIS_LIFE_WZ_HPZL @"juhe.apis.wz.hpzl" //3、車輛(號牌)種類編號查詢接口
/**
@brief 車輛違章查詢--4、接口剩餘次數查詢
*/
#define kJHAPIS_LIFE_WZ_STATUS @"juhe.apis.wz.status" //4、接口剩餘次數查詢
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_WZ_CITYS parameters : @{@"province":@"JS",@"dtype":@"json"} ] ;
/* 2、請求違章查詢接口 */
[self test : kJHAPIS_LIFE_WZ_QUERY parameters : @{@"dtype":@"json",@"city":@"SH",@"hphm”:@“蘇L50A11",@"hpzl":@"02"}] ;
/* 3、車輛(號牌)種類編號查詢接口 */
[self test : kJHAPIS_LIFE_WZ_HPZL parameters : @{@"dtype":@"json" }];
/* 4、接口剩餘次數查詢 */
[self test : kJHAPIS_LIFE_WZ_STATUS parameters : @{@"dtype":@"json" }];
}
- (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,全國車輛違章接口返回數據說明以及錯誤碼說明
1 . API : juhe.apis.wz.citys (宏 : kJHAPIS_LIFE_WZ_CITYS )
2 . API : juhe.apis.wz.query (宏 : kJHAPIS_LIFE_WZ_QUERY )
3 . API : juhe.apis.wz.hpzl (宏 : kJHAPIS_LIFE_WZ_HPZL )
4 . API : juhe.apis.wz.status (宏 : kJHAPIS_LIFE_WZ_STATUS )
錯誤碼
5, 更多聚合數據SDK接口,訪問這裏: http://www.juhe.cn/juhesdk/idocs