Get back in PHP JSON

Asked

Viewed 188 times

1

It has a system that will send a return to me every day, however I am not able to receive the data to record in the bank, someone can give me a light?

This is the data sent by the system

 -H 'Content-Type: application/json' \
  -d '{
    "uuid": "6ae29dfb29ad4dd29ce6bf454800c7db",
    "payment_type": "boleto",   
    "amount": 100,
    "status": "pending",   
    "external_id": "order 1",
    "expiration_date": "2018-07-13T21:00:00-03:00",
    "created_at": "2018-07-11T16:51:18-03:00"
}'

I need to get uuid, expiration_date and status to record to the bank!

1 answer

2


Try to use the function json_decode();

<?php
$json = json_decode(file_get_contents('php://input'), true);
$uuid = $json['uuid'];
$payment_type = $json['payment_type'];
$amount = $json['amount'];
$status = $json['status'];
$external_id = $json['external_id'];
$expiration_date = $json['expiration_date'];
$created_at = $json['created_at'];
...
?>

Now only implement the database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.