jeudi 28 décembre 2017

get value using Guzzle in Laravel

Currently i'm using guzzle htttp library to request a parameter from the server, using the code below

    $url = '//localhost/cgi-bin/sport/do.cgi?'.str_replace(' ','+',$auth).'&who.cgi';  
    $client = new Client();
    $result = $client->get($url);
    $body = (string) $result->getBody()->getContents();
    dd($body);
     Auth::attempt(['username' =>trim($body), 'password' =>'xxxx']);

the output is the following:

results

"""
{\n
"username": "inventario"\n
}\n
"""

some time ago using the same code delivered only the string value "inventario", but now it returns the json as shown above , how can i get only the needed value "inventario"??

Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire