This repository contains a few easy to follow examples build in PHP, which consume the AI-on-Demand API (AIoD API version 0.3.20220501) to send and/or retrieve data.
- Basic understanding of the PHP coding language
- A local development environment which allows execution of PHP code
- Docker to install & run the AI-on-Demand API (AIoD API)
- Composer for the advanced examples
Clone this repository to your local machine by running the following command:
git clone [email protected]:aiondemand/aiod-api-examples-php.gitAn aiod-api-examples-php folder will be created with the contents of this repository. Do not change to that folder, as you also have to clone, install & then run the AIoD API repository.
Clone the AIoD API repository to your local machine:
git clone [email protected]:aiondemand/AIOD-rest-api.gitChange to the newly created folder:
cd AIOD-rest-apiSwitch to version 0.3.20220501 of the API:
git checkout tags/0.3.20220501 -b 0.3.20220501Make sure that Docker is running on your machine and then install the AIoD API by following the installation instructions.
docker network create sql-network
docker run -e MYSQL_ROOT_PASSWORD=ok --name sqlserver --network sql-network -d mysql
docker build --tag ai4eu_server_demo:latest -f Dockerfile .
docker run --network sql-network -it -p 8000:8000 --name apiserver ai4eu_server_demoTIP: There's no reason to repeat this process after the initial installation, as you can start the AIoD API by running
docker start sqlserverfollowed bydocker start apiserver.
At this point you should be able to access the API using your web browser at localhost:8000. This instance operates at your own machine independently of the actual AIoD API, ensuring that real data is not accidentally modified or corrupted. In other words, it's the ideal playground for development or testing!
- Simple "Hello World!" example: Using PHP's cURL to insert a News item: This example demonstrates how easy it is to store information on the AIoD API using PHP's built-in cURL.
- Advanced "Hello World!" example: Using API client libraries to insert a News item: The integration process with the AIoDP API can be greatly simplified and streamlined with the utilisation of SDK libraries created automatically via Swagger Codegen.
Enjoy the AIoD API!