所以我目前正在获取json数组响应:
{“ state”:“ TO_BE_CREATED”,“ btc_amount”:0.1,“ btc_dest_address”:“ 1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb”,“ uuid”:“ xmrto-YHxJap”}
这是我的php代码:
$client = new GuzzleHttp\Client();
$data = [
"btc_dest_address" => '1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb',
"btc_amount" => '0.1'
];
$result = $client->post('https://xmr.to/api/v2/xmr2btc/order_create/', ['json' => $data]);
print "<pre>";
print_r( $result->getBody()->getContents() );
print "</pre>";
但是我只想从json中获取特定值,例如uuid,我该怎么做?
答案 0 :(得分:0)
看起来您只需要使用json_decode
即可将其变成可以使用的对象:
$data = json_decode($response->getBody());
echo $data->uuid;
这是您要找的吗?