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

bobdebower's avatar

where do i use this variable? please help

before the post, i want to use this variable $auth = $this->authenticate();

where do i use it here? please help

  $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
4 replies
bobdebower's avatar

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 from here ($auth = $this->authenticate();)

  $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',
   ]
]

Please or to participate in this conversation.