这里我需要打印来自CURL的json输出。
这是输出
{"call_id":"df0213a216b2af6767955e4052fb084b","to":"XXXXXXXX","status":"0","error_text":"Success"}
类似于call_id值,To值和状态值
这里我的编码和我也试过很少的方法
$phoneno = "Test";
$fields = array('api_key' => 'XXXXX',
'api_secret' => 'XXXX',
'to' => 'XXX',
'from' => 'XXXX',
'text' => $phoneno);
$url = 'https://api.nexmo.com/tts/json?' .http_build_query($fields, '', "&");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
print_r($response);
$json_output = json_decode($response, true);
echo "Trying to print ### ".$text = $json_output[0]->call_id;
foreach ($json_output as $trend){
echo $trend['call_id']."\n";
echo $trend['status']."\n";
echo $trend['error_text']."\n";
}
知道怎么做。 ??
答案 0 :(得分:2)
这应该有用......
echo $json_output['call_id']."\n";
echo $json_output['status']."\n";
echo $json_output['error_text']."\n";