I am using an API using cURL in PHP, and I need to get the value "responses" from some JSON that it returns, but everytime I try, it just returns the entire array of JSON. Here is my code so far for the API:
<?php
    $url = 'https://devman.kuki.ai/atalk';
     
    $curl = curl_init();
     
    $fields = array(
        'botkey' => '41c131bcce47671608b684cae353c7c53c6ad32dea6f92d58c316c9a0a5635d4',
        'input' => 'WHat is your name?'
    );
     
    $fields_string = http_build_query($fields);
     
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, TRUE);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_string);
     
    $data = curl_exec($curl);
    
    curl_close($curl);
?>
Adding this code:
 url_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 $data = curl_exec($curl);
 $jsn =  json_decode($data,1);
 echo "Response= " . $jsn['responses'][0] . "\n\n";
 var_export($jsn);
 echo "\n\n$data";
 curl_close($curl);
Will give you:
Response= My name is Kuki.
array (
  'status' => 'ok',
  'responses' => 
  array (
    0 => 'My name is Kuki.',
  ),
  'sessionid' => 3771193866,
  'channel' => 56,
  'client_name' => 'uuiprod-kdp5f6bce4a8268a350-user-0311',
)
{ "status": "ok", "responses": ["My name is Kuki."], "sessionid": 3771193866 , "channel": 56 , "client_name": "uuiprod-kdp5f6bce4a8268a350-user-0311"}
 
    