I made a simple API with PHP
When I call it (Postman or script) with https://www.example.org/api/index_api.php
it works. I get the return value.
When I call it (Postman or script) with https://www.example.org/api/
it doesn't.
Object sent
{"id": "alberto","name": "test name naaame ","email": "jane@doe.com"}
index_api.php (simplified: here, I don't use $method
):
<?phpheader('Content-type: application/json; charset=utf-8');$method = $_SERVER['REQUEST_METHOD'];//$input = json_decode(file_get_contents('php://input'), true);$input = mb_convert_encoding($input, 'HTML-ENTITIES', "UTF-8");//echo json_encode(['3' => 'De vuelta de API : ' . $input['name'] ]);
I'd be really grateful to receive some help.
I tried a lot of URL rewrite rules in .htaccess, but no success.
When it's for myself, I use complete path but it's not an API.And I need to call it
- for clients
- from inside a WP plugin
Thanks by advance