Answer the question
In order to leave comments, you need to log in
How to make a REST API application in PHP?
Hello, I have a problem understanding the assignment.
It is necessary to develop a RESTful API for the service. I understand how to make a service in PHP + MySql, but as I understand it, instead of a sql database, you need to use JSON.
After browsing the Internet, they mainly connect third-party resources such as a framework, cURL (I don’t know what it is). But because of the framework, incomprehensible things have only become more, so I want to write as simplified code as possible in pure PHP.
I do not understand how to implement this at all and where to start!
Answer the question
In order to leave comments, you need to log in
JSON is there as a request (and response) format. DB as you wish.
Describe API specs in swagger , it will also generate a server for you.
The main functions for implementation in "pure" PHP:
1. preg_match (control of the input data of the request),
2. switch (branching to the necessary API functions),
3. json_* (encode / decode)
4. hash (signature of requests)
$r = bin2hex(random_bytes(16));
$t =time();
$token='client token';
$params=array(
'value1'=>1,
'value2'=>'test'
);
$data=http_build_query($params);
$hash=hash('sha256',$r.$t.$token.$data);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question