i am new programmer. and i am using Google Distance Matrix API. I am first time using JSON . i use the Following but can't get response from server.. please give me few lines code for use JSON and fetch the distance in kilometer between two places.
http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&sensor=false
Thanks
when i use the following API i receive the response
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewdidload");
responseData = [[NSMutableData data] retain];
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:@"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"didReceiveResponse");
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError");
label.text = [NSString stringWithFormat:@"Connection failed: %@",
[error description]];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"connectionDidFinishLoading");
NSString* newStr = [[NSString alloc] initWithData:receivedData
encoding:NSUTF8StringEncoding];
[self handleResponce:newStr];
// NSLog(@"%@",newStr);
}
-(void)handleResponce:(NSString *)data
{
NSLog(@"receive data is --------->%@",receiveData);
}