guzzle and last fm API

242 views Asked by At

I'm using Laravel for about one month and i wanted to try the guzzle module, to get last fm user infos

I've tried this request in my controller :

$client = new \GuzzleHttp\Client(['base_uri' => 'http://ws.audioscrobbler.com/']);
        //$client = new \GuzzleHttp\Client();
        $response = $client->get('2.0/?method=user.getinfo&user=rj&api_key=xxxxxxxxxx&format=json');
        dd($response);

but i've just got this kind of things

Response {#190 ▼
  -reasonPhrase: "OK"
  -statusCode: 200
  -headers: array:11 [▼
    "date" => array:1 [▶]
    "server" => array:1 [▼
      0 => "Apache/2.2.22 (Unix)"
    ]
    "x-web-node" => array:1 [▼
      0 => "www223"
    ]
    "access-control-allow-origin" => array:1 [▼
      0 => "*"
    ]
    "access-control-allow-methods" => array:1 [▼
      0 => "POST, GET, OPTIONS"
    ]
    "access-control-max-age" => array:1 [▼
      0 => "86400"
    ]
    "cache-control" => array:1 [▼
      0 => "max-age=60"
    ]
    "expires" => array:1 [▶]
    "content-length" => array:1 [▼
      0 => "642"
    ]
    "connection" => array:1 [▶]
    "content-type" => array:1 [▶]
  ]
  -headerLines: array:11 [▶]
  -protocol: "1.0"
  -stream: Stream {#181 ▼
    -stream: :stream {@237 ▼
      wrapper_type: "PHP"
      stream_type: "TEMP"
      mode: "w+b"
      unread_bytes: 0
      seekable: true
      uri: "php://temp"
      options: []
    }
    -size: null
    -seekable: true
    -readable: true
    -writable: true
    -uri: "php://temp"
    -customMetadata: []
  }
}

Could someone help me with an example or something :) ?

1

There are 1 answers

2
marioquartz On BEST ANSWER

For body's contents:

echo $response->getBody();