Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Guzzle6中使用URI模板?_Php_Laravel_Guzzle6 - Fatal编程技术网

Php 在Guzzle6中使用URI模板?

Php 在Guzzle6中使用URI模板?,php,laravel,guzzle6,Php,Laravel,Guzzle6,我不能在Guzzle 6中使用URI模板 我的代码(已更新): self::$client=新客户端([“基本uri=>”http://example.com/api/“,”cookies“=>true]); $result=self::$client->get([“project/{projectId},[“projectId”=>$projectId]]) 我已经检查了旧文档和问题,但无法使其工作 引发的异常是:URI必须是字符串或URI接口 我找不到任何与Guzzle 6相关的文档。Guz

我不能在Guzzle 6中使用URI模板

我的代码(已更新):

self::$client=新客户端([“基本uri=>”http://example.com/api/“,”cookies“=>true]);
$result=self::$client->get([“project/{projectId},[“projectId”=>$projectId]])

我已经检查了旧文档和问题,但无法使其工作

引发的异常是:URI必须是字符串或URI接口


我找不到任何与Guzzle 6相关的文档。

Guzzle的
get
方法定义为
get(string | UriInterface$uri,array$options=[])
,并且您将数组作为
$uri
传递,这在这里是不允许的。 您必须自己构建uri,因为guzzle不适合您

正确的代码块应该如下所示(如果
projectId
是整数):


$result=self::$client->get(sprintf('project/%d',$projectd))

添加整个代码