0
I am creating a Restful web service in PHP. I am not using any framework.
I am following the recommendations of standards or best practices for developing web Apis, suggested by the White House.
On their website, already in the first line, we find the following recommendation of a URL to recover a resource:
List of magazines:
GET http://www.example.gov/api/v1/magazines.json
So I didn’t understand how to funnel this URL finished in ". json", because all pages of the project should end in ". php" correct?
The closest I could get was
http://www.example.gov/api/v1/magazines.json.php
but still the ending ". php" needs to be included in the URL or code that will consume the service.
So here’s my question: How to make a URL that ends in .json be recognized by the URL or API code to point to the right place that will handle the request and return a JSON?
Definitely that kind of address:
http://www.example.gov/api/v1/magazines.json
are created routes but as you are doing without framework can finish.php
hassle-free!– novic
Virgilio, thank you, I didn’t even realize it. Then this route '.json' should be part of some application using a framework, which in turn should do some treatments ( that combine '.htaccess' and/or the variable '$_SEVER' for example). If I want to make ". json" be responsive I would have to work with.htaccess and/or '$_SERVER' tbm, correct?
– zwitterion
.json
in the case ai of routes are names, and can be any name (has a pattern in some framework, but in general can be any name) this confused you a little I believe, but, do not worry if you dohttp://localhost/c.php
if you return the data correctly is what matters! what matters most is the security and return of json !– novic
ok. thanks. put your answer there
– zwitterion