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

migdalius's avatar

Soap Api with model?

Hello, i have standard api connection:

$address = 'https://growtent.iai-shop.com/api/?gate=products/get/84/soap';
        $wsdl = $address . '/wsdl';
        $binding = array();
        $binding['location'] = $address;
        $binding['trace'] = true;
        $client = new SoapClient($wsdl, $binding);

        $login = "LOGIN"; 
        $password = "PASSWORD";

        $request = array();
        $request['get'] = array();
        $request['get']['authenticate'] = array();
        $request['get']['authenticate']['userLogin'] = $login;
        $request['get']['authenticate']['authenticateKey'] = sha1(date('Ymd') . sha1($password));

        

Here is call where i take active produkt, 10 product and only on Category name: Test

$request['get']['params'] = array();
        $request['get']['params']['returnProducts'] = "active";
        $request['get']['params']['productIsAvailable'] = "y";

        $request['get']['params']['resultsLimit'] = 10;
        $request['get']['params']['categories'][0]['categoryName'] = "Test";
        
        $response = $client->__call('get', $request);

When i wana just make messy but still working controller i make:

<?php


namespace App\Http\Controllers;


use Illuminate\Http\Request;
use SoapClient;

class WelcomeController extends Controller
{
    public function index()
    {
        return view('welcome');
    }

    public function connect(){

        $address = 'https://growtent.iai-shop.com/api/?gate=products/get/84/soap';
        $wsdl = $address . '/wsdl';
        $binding = array();
        $binding['location'] = $address;
        $binding['trace'] = true;
        $client = new SoapClient($wsdl, $binding);

        $login = "LOGIN"; 
        $password = "PASSWORD";

        $request = array();
        $request['get'] = array();
        $request['get']['authenticate'] = array();
        $request['get']['authenticate']['userLogin'] = $login;
        $request['get']['authenticate']['authenticateKey'] = sha1(date('Ymd') . sha1($password));

        $request['get']['params'] = array();
        $request['get']['params']['returnProducts'] = "active";
        $request['get']['params']['productIsAvailable'] = "y";

        $request['get']['params']['resultsLimit'] = 1;
        $request['get']['params']['categories'][0]['categoryName'] = "Test";
        
        $response = $client->__call('get', $request);

        return $response;

    }



}

My route look like:


Route::get('/', ['as'=>'connect', 'uses'=>'WelcomeController@connect']);

and welcome.blade

  <?php print_r($response); ?>

But still is not work:

The Response content must be a string or object implementing __toString(), "object" given.

0 likes
0 replies

Please or to participate in this conversation.