Laravel - Guzzle Request / cURL error 6: Could not resolve host

前端 未结 4 1538
隐瞒了意图╮
隐瞒了意图╮ 2021-01-20 22:50

I try to make an API Request to the Github API just for testing. I installed the latest Guzzle Version ( \"guzzle/guzzle\": \"^3.9\" ) on my Laravel 5.1 APP. In my routes

4条回答
  •  清歌不尽
    2021-01-20 23:37

    Actually a variable interpolation is not possible within single quotes. This means that you currently are calling users/$username and the $username variable gets not replaced with its value.

    In order to get it, you should use it in one of the following ways:

    $response = $client->get("users/$username")->send();
    $response = $client->get('users/' . $username)->send();
    

    I personally prefer the second one as it is assumed to be faster.

提交回复
热议问题