狂饮和最后的fm API
我正在使用Laravel大约一个月,我想尝试guzzle模块,以获取最后的fm用户信息 我已在控制器中尝试此请求:狂饮和最后的fm API,api,laravel-5,guzzle,last.fm,Api,Laravel 5,Guzzle,Last.fm,我正在使用Laravel大约一个月,我想尝试guzzle模块,以获取最后的fm用户信息 我已在控制器中尝试此请求: $client = new \GuzzleHttp\Client(['base_uri' => 'http://ws.audioscrobbler.com/']); //$client = new \GuzzleHttp\Client(); $response = $client->get('2.0/?method=user.getinf
$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);
但我有这种东西
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: []
}
}
有人能帮我举个例子吗:)?关于正文内容:
echo $response->getBody();
谢谢!:)但是我如何才能精确地获得数组,例如艺术家的名字?data=json\u decode($response->getBody(),true)代码>$数据内容包含一个包含信息的数组。使用var\u dump($data)代码>您应该可以看到完整的数组。