为什么我不能在 laravel 控制器中使用 GuzzleHttp?
Why can't I use GuzzleHttp in laravel controller?
不断收到以下错误:
classIlluminate\Routing\Route 的对象无法转换为字符串
$response = $client.post('url', [
'body' => [
'blah' => 'blah'
],
'headers' => [
// client id+client secret (base64)
'Authorization' => 'Basic sllalalalal='
]
]);
我没有在任何地方使用路由对象,数组中的所有字符串都是硬编码的。发生错误的行正是分号所在的位置。
将 $client.post
更改为 $client->post
。目前您正在尝试连接 $client
和 post()
.
Guzzle 4
PHP 5.4.x+ 需要
composer require "guzzlehttp/guzzle" "~4.0"
$client = new \GuzzleHttp\Client();
$response = $client->post('url', [
'body' => [
'blah' => 'blah'
],
'headers' => [
// client id+client secret (base64)
'Authorization' => 'Basic sllalalalal='
]
]);
不断收到以下错误:
classIlluminate\Routing\Route 的对象无法转换为字符串
$response = $client.post('url', [
'body' => [
'blah' => 'blah'
],
'headers' => [
// client id+client secret (base64)
'Authorization' => 'Basic sllalalalal='
]
]);
我没有在任何地方使用路由对象,数组中的所有字符串都是硬编码的。发生错误的行正是分号所在的位置。
将 $client.post
更改为 $client->post
。目前您正在尝试连接 $client
和 post()
.
Guzzle 4
PHP 5.4.x+ 需要
composer require "guzzlehttp/guzzle" "~4.0"
$client = new \GuzzleHttp\Client();
$response = $client->post('url', [
'body' => [
'blah' => 'blah'
],
'headers' => [
// client id+client secret (base64)
'Authorization' => 'Basic sllalalalal='
]
]);