Aggregated data iOS SDK national gas station [real-time oil price] Demo Example

Source: Internet
Author: User

1. Add the Aggregation Data SDK (Juheapis.framework) to your program, and the packages that the SDK relies on include:

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, locate the Courier Query interface macro in the JHSDKAPIPath.h file of the Aggregation SDK framework, and the dictionary parameters

/*** National gas station [real-time oil price] ***/
/**
@brief National gas station [real-time oil price]- > Search by City Gas station
@param city string must be filled UrlEncode UTF8;
@param page int is not required, default 1
*/
#define Kjhapis_life_oil_region @ "Juhe.apis.oil.region"//1, search by City gas station

/**
@brief The national gas station [real-time oil price], search peripheral gas station
@param lon double required longitude (such as: 121.538123)
@param lat double required latitude (such as: 31.677132)
@param r int Non-required search range, Unit m, default 3000, maximum 10000
@param page int not required, default 1
*/
#define KJHAPIS_LIFE_OIL_LOCAL @ " Juhe.apis.oil.local "//2, retrieve the surrounding gas station


3, express query interface call method in program (change VIEWCONTROLLER.M to. 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];
additional setup after loading the view, typically from a nib.
[[Jhopenidsupplier Sharesupplier] registerjuheapibyopenid:@ "applied to the OpenID"];

uibutton* Beginbtn=[uibutton Buttonwithtype:uibuttontypesystem];
Beginbtn.frame=cgrectmake (111, 280, +);
[beginbtn settitle:@ "Start" 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, search by City gas station */
[self test:kjhapis_life_oil_region parameters:@{@ ' city ': @ "Suzhou", @ "page": @ "1"}];


/* 2, search the surrounding gas station * *
[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*** \%@", 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, can be recreated.
}

@end


4, national gas station [real-time oil price] interface return data description and error code description

4.1, according to the city search station

API:JUHE.APIS.OIL.REGION (Macro : kjhapis_life_oil_region)

return field:

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, search the surrounding gas station
API:JUHE.APIS.OIL.LOCAL (Macro : 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. National gas station [real-time oil price] error code

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, more Aggregation Data SDK interface, Access here: Http://www.juhe.cn/juhesdk/idocs



This article is from the "aggregated Data" blog, reproduced please contact the author!

Aggregated data iOS SDK national gas station [real-time oil price] Demo Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.