彙總資料iOS SDK 全國加油站[即時油價]示範樣本

來源:互聯網
上載者:User

標籤:加油站   快遞查詢   程式   介面   sdk   api   

1,將彙總資料SDK(JuheApis.framework)添加到你的程式中來,SDK依賴的包包括:

650) this.width=650;" src="http://img.blog.csdn.net/20141009100644765?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvU29yb3NX/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="SouthEast" />


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) 

返回欄位 :

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4C/31/wKioL1Q4lrvhGpnVAAJY5OJ7SWY774.jpg" style="float:none;" title="1.png" alt="wKioL1Q4lrvhGpnVAAJY5OJ7SWY774.jpg" />

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

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4C/30/wKiom1Q4loThWQW1AAKBH5H0h9I355.jpg" style="float:none;" title="2.png" alt="wKiom1Q4loThWQW1AAKBH5H0h9I355.jpg" />

4.3. 全國加油站[即時油價] 錯誤碼

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/4C/30/wKiom1Q4loTREODcAACsrblZ_ec850.jpg" style="float:none;" title="3.png" alt="wKiom1Q4loTREODcAACsrblZ_ec850.jpg" />



5, 更多彙總資料SDK介面,訪問這裡: http://www.juhe.cn/juhesdk/idocs



本文出自 “彙總資料” 部落格,轉載請與作者聯絡!

彙總資料iOS SDK 全國加油站[即時油價]示範樣本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.