https://github.com/tobie-rathbun/restful_api--method-testing
A RESTful API built in PHP that listens to calls from a desktop Python application
https://github.com/tobie-rathbun/restful_api--method-testing
Last synced: about 1 year ago
JSON representation
A RESTful API built in PHP that listens to calls from a desktop Python application
- Host: GitHub
- URL: https://github.com/tobie-rathbun/restful_api--method-testing
- Owner: Tobie-Rathbun
- Created: 2023-04-16T04:46:27.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-20T21:12:47.000Z (over 2 years ago)
- Last Synced: 2025-01-22T20:15:45.264Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 5.86 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Tools Summary:
PHP API (api.php):
Purpose: Handles incoming POST requests, processes JSON data, and stores items in a file (items.txt).
Key Feature: Responds with a success message if the item is created.
Python Script:
Purpose: Sends a POST request to the PHP API (api.php).
Key Features: Uses the requests library to send a POST request with JSON data. Displays response details.
How to Use:
Setting Up the PHP API (api.php):
Install XAMPP:
Install XAMPP on your machine.
Copy to htdocs:
Place the provided my_api folder inside the htdocs directory of your XAMPP installation.
Running the Python Script:
Check API URL:
Ensure the URL in the Python script points to your PHP API (http://localhost/my_api/api.php).
Install Required Package:
If not installed, run pip install requests to install the requests library.
Execute Script:
Run the Python script from the terminal using python your_script_name.py.
Review Output:
Check the terminal output for information on the request and response.
Testing with Simple Rest Client in VS Code:
Install Simple Rest Client:
Install the "REST Client" extension in VS Code.
Open Simple Rest Client:
Click on the "Send Request" link in your Python script file.
Configure Request:
Set the method to POST.
Enter the URL as http://localhost/my_api/api.php.
Headers and Body:
Configure headers if needed.
Enter JSON data in the body (e.g., {"item": "Test Item"}).
Send Request:
Click the "Send Request" button.
Review Response:
Check the response in the client for the status, message, and item details
Alternatively look at the updated .txt C:/xampp/htdocs/my_api/items.txt