Answer the question
In order to leave comments, you need to log in
How to make a get request with Guzzle?
I work with the library https://github.com/guzzle/guzzle , or rather I get acquainted.
The situation is as follows:
There is an api to which the client is written in php. To send methods, I chose this library. I need to send a post request, get an access token and then work with it by sending get requests.
Sending a post request:
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'http://api.site.com/oauth2/user', [
'form_params' => [
'username' => '***',
'password' => '***',
]
]);
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://api.site.com/v1/groups', [
// 'form_params' => [
'access_token' => $token,
// ]
]);
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://api.site.com/v1/groups?access_token=' . $token);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question