-1

So i currently am getting the json array response :

{"state":"TO_BE_CREATED","btc_amount":0.1,"btc_dest_address":"1FhnVJi2V1k4MqXm2nHoEbY5LV7FPai7bb","uuid":"xmrto-YHxJap"}

This is my php code:

$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>";

But i want to get only a specific value from that json which would be for example uuid , how could i do this ?

Gongas
  • 87
  • 7

1 Answers1

1

Looks like you just need to use json_decode to turn it into an object you can use:

$data = json_decode($response->getBody());
echo $data->uuid;

Is this what you're looking for?

matt
  • 670
  • 2
  • 9
  • 18