Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JSON response form server--Urgent

    Hi All,
    I'm copy an API on web browser (Its like this).I get response,
    https://fridaycamp.ca/api/v1/version...1becbb188b91ed....

    I get response
    {"status": "ok", "version": "1.1.0"}


    I have sample other responses where I get by using cURL.

    I need to extract this data from the server and load it into another server.I'm horribly confused.

    Here's the whole picture.

    We have original data on server1
    We can access the server1 data using only API requests.I sent API request to server1 and got the responses in JSON.
    I need to extract the data from JSON responses and then load into SQL server which is on server2.
    I'm connected to server 2(that's where I have to write the code to extract the data)

    What is the best way to extract this data from server1 to server2?

    Should I write Java script/PHP to extract the data from server1 and load it into server2?

    Should it be written in Phython?or ......?

    Any ideas would be appreciated at this point of time.

    It's very urgent.

    Thank You.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,719
    Thanks
    25
    Thanked 660 Times in 659 Posts
    I get response
    {"status": "ok", "version": "1.1.0"}
    I don't think that's correct. In this case i think json sends you a string that looks like that and you printed the string. Use PHP because you want to enter data into a database.

    Something to help you see whats going on:
    PHP Code:
    <?php
    $string 
    '{"status": "ok", "version": "1.1.0"}';  // THE VARIABLE $string IS WHAT IS SENT TO YOU

    /*  DID THID SO YOU CAN SEE THE JSON STRING DECODED  */
    $decoded json_decode($string);
    print 
    "Status: ".$decoded->{'status'}."<br />";
    print 
    "Version: ".$decoded->{'version'};

    /*  OR USE THESE VARIABLES TO ADD INFO TO THE DATBASE  */
    $status $decoded->{'status'};
    $version $decoded->{'version'};
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •