response CurlRequest postRequest link env REPLUG_URL oauth token data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$response = CurlRequest::postRequest([
'link' => env('REPLUG_URL').'oauth/token',
'data' => [
'grant_type' => 'authorization_code',
'client_id' => REPLUG_CLIENT_ID,
'client_secret' => REPLUG_CLIENT_SECRET,
'redirect_uri' => REPLUG_CALLBACK_URL,
'code' => code]
]);
# replace code, redirect_uri , client_secret and client_id
// post method
use GuzzleHttp\Client;
public static function postRequest($details)
{
$http = new Client();
$response = $http->post($details['link'], []);
return json_encode([
'status' => true,
'status_code' => $response->getStatusCode(),
'body' => $response->getBody()->getContents(),
]);
}