Calling API to get JSON string

  1. last week

    Tim W

    Sep 13 Pre-Release Testers, Xojo Pro Solingen, Germany

    For a customer i need to call an API to get a JSON String. I didn't succeed, doing this with xojo.

    I know how to call the Interface with php:

    header('Content-type: application/json');
    define('API_ID', '1234');
    define('API_KEY', 'abcdefghijk1234567890');
    define('API_FORMAT', 'json'); #or xml
    define('API_URL', 'https://api.service.tld/vxyz/'.API_FORMAT.'/'.API_ID.'/'.API_KEY.'/');
    
    # Get statistics
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, API_URL.'ACD/Statistics/Agents');
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
    echo curl_exec($ch);
    curl_close($ch);

    Running this code on a webserver i get the JSON-String in the browser.
    I think i know how to parse this string in xojo, but i don't have an idea how to call the API, and then parse the result, and getting the data from the string.

    Thanks for any kind of tip.....

    For a synchronous request, start here:

    http://docs.xojo.com/index.php/HTTPSecureSocket

    And look in the examples folder. There’s at least one example that talks about secure sockets.

  2. Greg O

    Sep 13 Xojo Inc Answer Somewhere near Raleigh, NC

    For a synchronous request, start here:

    http://docs.xojo.com/index.php/HTTPSecureSocket

    And look in the examples folder. There’s at least one example that talks about secure sockets.

  3. Tim W

    Sep 13 Pre-Release Testers, Xojo Pro Solingen, Germany

    Thanks Greg,
    i succeded with one of the examples.

    First i didn't know how to use the options, but now it's clear for me. I just had to put together the variables to one URL-String.

or Sign Up to reply!