我正在尝试进行API调用。使用配置api标记给出错误'URI必须是字符串或UriInterface'Laravel
如果我这样做:$url = "url-code.com?param1=value1¶m2=value2&_token=enter-key-here";
我没有得到任何错误。
如果我这样做:$url = "url-code.com?param1=value1¶m2=value2&_token="+Config::get('app.john_doe_key');
我得到一个错误: 'URI必须是一个字符串或UriInterface'
mycode的
$statusCode = 200;
$url = "url-code.com?param1=value1¶m2=value2&_token="+Config::get('app.john_doe_key');
$client = new Client();
$res = $client->get($url);
//dd($res);
return $res->getBody();
.ENV
JOHN_DOE_APP_KEY=key
config/app .PHP
'john_doe_key' => env('JOHN_DOE_APP_KEY'),
好奇,你使用配置助手会发生什么? '配置( 'app.john_doe_key')'?这就是说,你也可以使用配置文件吗? –
似乎'Config :: get('app.john_doe_key')'为空。它打印什么? – Yolo
你用+来追加字符串吗? – manian