I'm trying to send a data by getting from an Angular 5 service to an API in PHP.
The way I send it is like this:
public getMembers$(id): Observable<any> {
return this.http.get(this.URL + 'read_records.php?id=1');
}
The variable this.URL comes from the environments and it's not a problem. The API is reached by the service, that's what I see in the network call.
The problem is that in the API I can not recover the id variable sent. I've tried it with $_GET
and with file_get_contents("php://input")
and there's no way.
What is the correct way to retrieve variables in the API when sent from Angular? For the http.post
method if the php://input
works for me (provided that what I send is serialized in a json), but there are more types of submissions (send by post of files, send by get, or put or delete).
How can I recover that data in PHP?