致命错误:使用Guzzle 6调用未定义的方法GuzzleHttp \ Client :: request() [英] Fatal error: Call to undefined method GuzzleHttp\Client::request() with Guzzle 6

查看:1033
本文介绍了致命错误:使用Guzzle 6调用未定义的方法GuzzleHttp \ Client :: request()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Laravel 5.2上使用了Guzzle 6.

I'm using Guzzle 6 with Laravel 5.2.

我正在尝试访问一个简单的内部API:

I'm trying to access a simple internal API:

use GuzzleHttp\Client;

        $client = new Client(['base_uri' => getenv('URL_BASE').'api/v1/']);
        $response = $client->request('GET', 'tournaments');

我收到此消息:

Fatal error: Call to undefined method GuzzleHttp\Client::request()

当我看到 docs 时,它说:

$client = new GuzzleHttp\Client(['base_uri' => 'https://foo.com/api/']);

但是PHPStorm无法解析GuzzleHttp

But PHPStorm cannot resolve GuzzleHttp

我应该怎么做才能使其正常工作?

What should I do to make it work???

推荐答案

我也正在使用guzzle,它对我有用,请尝试这样

I am also using guzzle, and its working for me, Try like this

use GuzzleHttp;
use GuzzleHttp\Subscriber\Oauth\Oauth1;

$client = new GuzzleHttp\Client();

要获得回应,请尝试

$response = $client->request('GET', 'tournaments',['query' => ['base_uri' => getenv('URL_BASE').'api/v1/']]);

或者尝试一下,如果不起作用

OR try this if not work

$response = $client->request('GET', getenv('URL_BASE').'api/v1/tournaments');

这篇关于致命错误:使用Guzzle 6调用未定义的方法GuzzleHttp \ Client :: request()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆