api.php
file contains API Code... At first it has to be hosted to any hosting platform. Then it can be called by any WEBSITE... This api has just GET method..
About api.php
Method-
This code creates an API in PHP that generates and returns a random number of the specified length when a GET request is made to the api.php
script with the len parameter in the query string. The HTML file contains a JavaScript script that uses the fetch()
function to make a GET request to the API and insert the response into an element on the page.
Testing Method
-
To test this example, you will need to upload the api.php and index.html files to your web server and access the index.html file in a web browser. The page should display a random number generated by the API.