Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7643203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:23:21+00:00 2026-05-31T09:23:21+00:00

i am new programmer. and i am using Google Distance Matrix API. I am

  • 0

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:23:22+00:00Added an answer on May 31, 2026 at 9:23 am

    What exactly is your problem?

    • Fetching the data?
    • Or parsing the JSON?
    -(void)viewDidLoad{
        [super viewDidLoad];
        NSLog(@"viewdidload");  
        responseData = [[NSMutableData alloc] init];  
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC%7CSeattle&destinations=San+Francisco%7CVictoria+BC&mode=bicycling&language=fr-FR&sensor=false"]];
        [[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");
    }
    -(void)connectionDidFinishLoading:(NSURLConnection *)connection{
        NSLog(@"connectionDidFinishLoading");
        NSString* newStr = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
        [self handleResponse:newStr]; // NSLog(@"%@",newStr);
    }
    -(void)handleResponse:(NSString *)string{
        NSLog(@"responseData data is --------->%@",string);
    }
    

    Try this. You sometimes referred to responceData, and sometimes to receiveData. I fixed that and the name of the method. Plus you were trying to log the responseData and not the String.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am new programmer.i am using Google Matrix API. i get the following response
I'm a long time programmer but new to Ruby. I'm trying to port an
I'm a fairly new programmer, but I consider my google-fu quite competent and I've
I'm a new Python programmer who is having a little trouble using 'self' in
I'm currently launching a programme using subprocess.Popen(cmd, shell=TRUE) I'm fairly new to Python, but
I'm a new-ish C++ programmer, and I'm doing my first program on my own
Good day (and happy New Year), I'm a beginner VB.Net programmer using VS 2008.
I am a new guy, a java programmer. Using namespace encountered difficulties in rails3.
Google/MyBrain are failing me. Without using a framework (which I'll never get past my
i am a new programmer in visual studio (using the 2008 version) i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.