L
L
love_fishing2018-07-05 16:57:22
PHP
love_fishing, 2018-07-05 16:57:22

How to generate a unique URL to which data is transmitted in json format?

Good afternoon. Created a site for quests. I want to join the aggregator. They have a condition:
Description of the site API ....... ru (so as not to advertise)
Getting the quest schedule
For each of your quests, you need to generate a unique URL, with a GET request for which we will receive a schedule for 2 weeks in json format.
Expected fields:
date: date, format YYYY-MM-DD
time: time, format HH:MM (24 hours)
is_free: boolean, where true means availability for booking. If the game time has passed, then return false
price: the price in rubles in the format of an integer
discount_price: an optional field that allows you to transfer the promotional cost of the game if the quest provides additional discounts (details below).
Also, you can send us additional parameters, which we will refund to you upon booking.
Example
# GET YOUR_WEBSITE/api/quests/timetable/4.json
[
{
"date": "2016-05-05",
"time": "18:30",
"is_free": true,
"price": 3000,
"your_slot_id": 123,
},
{
"date": "2016-05-05",
"time": "20:00",
"is_free": false,
"price": 3500,
"your_slot_id": 124,
} ,
]
Tell me where to start, where to dig. My WordPress site. Worth the team booking plugin.
I realized that I need to save the data in json format (again, I don’t understand how to do this) and then form a url ) on the GET site with a request to which (normal link?!) , which will open the page with this data?
I understand that everything was sooo illiterate and amateurishly described, but I'm just starting to learn something more complicated than just installing modules and plugins on different cms and I really want to figure out where to start. Right from scratch. Can anyone help to chew on what and how? Or direct me to useful resources to read there? I understand that there are a couple of hours to do, maybe even less. But, when there is no necessary knowledge, everything seems scary. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-07-05
@thewind

The simplest thing is that you need to write a plugin that will take all the data on quests from the database and output them directly to the browser in JSON format (i.e. you don’t need to save anything anywhere) with the necessary headers (optional). No header / footer, i.e. this is a service page. This page should always have the same URL, which you will come up with yourself and handle with your plugin.
As for the booking - apparently they will send data about the new booking (quest ID, date and time, your unique data - for example) to the URL that you provide them. Based on these data, you must make a note in yourself that the reservation has been accepted and in the future for this time slot / this quest display is_free: false

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question