聚合數據iOS SDK 快遞查詢演示示例

1,將聚合數據SDK(JuheApis.framework)添加到你的程序中來,SDK依賴的包包括:



2,在聚合SDK Framework的JHSDKAPIPath.h文件中找到快遞查詢接口宏,以及字典參數

/*** 常用快遞 ***/
/**
@brief 常用快遞 -> 常用快遞查詢API
@param com string 是 需要查詢的快遞公司編號
@param no string 是 需要查詢的訂單號
@param dtype string 否 返回數據的格式,xml或json,默認json
*/
#define kJHAPIS_LIFE_EXP_INDEX @"juhe.apis.exp.index" //1、常用快遞查詢API

/**
@brief 常用快遞 -> 快遞公司編號對照表
*/
#define kJHAPIS_LIFE_EXP_COM @"juhe.apis.exp.com" //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
{
// /* 常用快遞 */
[self test:kJHAPIS_LIFE_EXP_INDEX parameters:@{@"com":@"sf" , @"no":@"575677355677"}];
[self test:kJHAPIS_LIFE_EXP_COM parameters:@{}];
}

- (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.exp.index (宏:kJHAPIS_LIFE_EXP_INDEX)


返回字段:

wKioL1Q4xHrybReGAAF9MHA-SWI394.jpg

4.2 API :juhe.apis.exp.com(宏:kJHAPIS_LIFE_EXP_COM)

返回字段:

wKioL1Q4xHrQ_yApAADRWI9PNm0964.jpg

4.3 常用快遞錯誤碼

wKiom1Q4xEOgJhtpAACUeTVLBLE985.jpg

5, 更多聚合數據SDK接口,訪問這裏: http://www.juhe.cn/juhesdk/idocs


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章