ios - UNIRest objective c Currency Converter Api -
i trying use currency converter api mashape located @ https://www.mashape.com/ultimate/currency-convert#!
i new objective-c. trying call api through code -
nsdictionary* headers = @{@"x-mashape-authorization": @"key"}; nsdictionary* parameters = @{@"amt": @"2", @"from": @"usd", @"to": @"inr", @"accuracy": @"2"}; unihttpjsonresponse* response = [[unirest post:^(unisimplerequest* request) { [request seturl:@"https://exchange.p.mashape.com/exchange/?amt=120&from=usd&to=gbp&accuracy=3&format=json"]; [request setheaders:headers]; [request setparameters:parameters]; }] asjson];
can tell me how can access information returned , how send parameter 2 number instead of string.
thanks help.
it seems mashape's apis not standardized point of taking parameters parameter array - need pass them in seturl call of unihttpjsonresponse object.
also, using async calls when getting data remote api idea.
nsdictionary* headers = @{@"x-mashape-authorization": @"key"}; [[unirest post:^(unisimplerequest* request) { [request seturl:@"https://exchange.p.mashape.com/exchange/?amt=120&from=usd&to=gbp&accuracy=3&format=json"]; // want set currencies, amounts, etc. [request setheaders:headers]; [request setparameters:@{}]; // needed? dunno }] asjsonasync:^(unihttpjsonresponse* response, nserror *error) { if (error) { nslog(@"%@",[error localizeddescription]); } else { // here stuff want data got. // launch code deals data :) nsdictionary *currencyresult = [nsjsonserialization jsonobjectwithdata:[response rawbody] options: 0 error: &error]; nslog(@"%@", currencyresult); } }];
Comments
Post a Comment