I want to try out the guzzle library and am following through their quickstart tutorial to make http requests to an api.

Yet it doesn't seem to work, because I get the following error:

cURL error 3: <url> malformed

Since I have never worked with cURL before, I don't even know how to respond to that error message. Here is my code with the request I am making:

    $client = new Client();
    $client->get('/', ['verify' => true]);

    $response = $client->get('https://api.github.com/');

    dd($response);

I am using the Laravel 5 framework and calling the index method in my HomeController. Also am using WAMP.

I would appreciate any help and suggestion, because I would like to try Guzzle out.

Here is a picture of the Error Message I get:

Laravel 5 Error Message

推荐答案

If you want to disable verification (don't do this!):

$response = $client->get('https://api.github.com/', ['verify' => false]);

与其完全禁用验证,还不如通过提供适当的CABundle 文件来解决这一问题.参见Guzzle文档中的verify.

$client->setDefaultOption(
    'verify', 
    'C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt'
);

Laravel相关问答推荐

如何在 Laravel 中使用 return 停止 Trait php 的执行

我如何通过 laravel 在高图中针对不同的时间范围进行烛台数据分组

Laravel Eloquent:组合列(或自定义属性)上的 Where 子句

未找到 apiResource 404 中的变量

Laravel 5表单请求验证返回禁止错误

使用 Eloquent (Laravel) 在 Group By 之前排序

Laravel 没有定义

Laravel:如何在没有数据库的情况下对用户进行身份验证

使用 Laravel Socialite 登录 Facebook

Laravel Eloquent Pluck 不丢失密钥

在 Laravel 容器中覆盖单例

控制器外部的 Laravel 访问请求对象

Laravel assets资源与混合

Laravel 迁移命名约定

在 Laravel 应用程序中在哪里指定应用程序版本?

Laravel 字符串验证以允许空字符串

Laravel 在保存前生成 slug

Composer RuntimeException - 无法加载软件包 mews/purifier

Laravel 5 new auth:获取当前用户以及如何实现角色?

如何在没有日志(log)、没有信息的情况下调试 Laravel 错误 500