How to make a JSON response with url endpoint from a third party site

I have a problem syncing data from another site to my site with a JSON response. I got documentation from another site to direct some data to my site. The documentation states if I should create a URL endpoint and make a JSON response to get the data. This is the JSON response format I got from the documentation:

{
  "id": INTEGER, // Confirmation Number
  "type": STRING, // "new" or "update" or "cancel"
  "data": OBJECT // data element
}

      

In this case, my site uses a structure Codeigniter

. Who do I want to ask how to make this JSON response on my site? I have already created some function in the Controller

following way:

function json_response()
{

}

      

And I don't know what codes I should insert into Controller

. Thank.

+3


source to share


1 answer


If you're not sure what variable name is sending the JSON data, try var_dump the $ _POST variable to some table in your database, or write the values โ€‹โ€‹of the $ _POST variable to a file. By doing this, you can check what variables you got from this request.



+1


source







All Articles