Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bobdebower's avatar

WHERE to add this variable

hey i just want to know how to use this variable

     $auth = $this->authenticate();

from the class i created

 public function authenticate()
   {
//declaring auth variables
$username = env('API_USERNAME');
$password = env('API_PASSWORD');

   $auth = Http::withBasicAuth($username, $password);
  return $auth;
  }

how to implentent it $auth = $this->authenticate(); here???

   $amount = $request->get('amount');

 $client = new \GuzzleHttp\Client();

   $response = $client->post(
'  http://192.168.150.16:7585/api/v1/Transaction/GetTransactionNumber', 
   [
GuzzleHttp\RequestOptions::JSON => [
'Amount' => $amount,
'something' => '1',
'Description' => 'desc',
   ]
]
0 likes
2 replies

Please or to participate in this conversation.