GuzzleHttp \ Client返回404

时间:2014-08-15 08:52:13

标签: php api rest symfony guzzle

我已经开始使用GuzzleHttp \ Client了,我有问题从REST API获得响应,因为我收到错误404代码。我不理解它,因为当我从我的代码中复制url并粘贴到浏览器中时,我将看到json响应。你知道我做错了什么吗?

$client = new GuzzleHttp\Client();
$response = $client->get('http://login:password@url_to_api/get/some_products');
$json = $response->json();

1 个答案:

答案 0 :(得分:1)

我不认为您可以像这样添加登录凭据。 这是正确的方法:http://guzzle.readthedocs.org/en/latest/clients.html#auth