聚合数据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)

返回字段:

名称

 

 

类型

说明

error_code

 

 

int

错误码

resultcode

 

 

int

返回码

reason

 

 

string

返回说明

result

 

 

dictionary

返回结果

 
company

 

string

快递公司名称

 

com

 

string

快递公司编号

 

no

 

string

订单号

 

list

 

array

物流跟踪

 

 

datetime

string

时间

 

 

remark

string

描述

 

 

zone

string

区域

  

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

返回字段:

名称

 

类型

说明

error_code

 

int

错误码

resultcode

 

int

返回码

reason

 

string

返回说明

result

 

dictionary

返回结果

 

com

string

快递公司编号

 

no

string

订单号


  4.3 常用快递错误码


 

错误码

 

204301

未被识别的快递公司

 

204302

请填写正确的运单号

 

204303

加载类库失败

 

204304

查询失败


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

 

转载于:https://my.oschina.net/u/2009908/blog/325571

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值