Guzzle在有效的URL上返回404

时间:2015-06-19 09:55:44

标签: guzzle

我正在使用Guzzle和CurlAuthPlugin进行身份验证。当我运行代码时,我得到了

Client error response\ [status code] 404\ [reason phrase] Not Found\ [url] https:\/\/api.buto.tv\/v2\/video\/tag\/v2\/video\/tag\/

我正在使用的代码是:

$client = new Client(<URL>);

    // Add the auth plugin to the client object
    $authPlugin = new CurlAuthPlugin(<APIKEY>, 'x');
    $client->addSubscriber($authPlugin);

    $response = $client->get('v2/video/tag/')->send();

但是网址完全有效,我可以将其粘贴到浏览器中并且工作正常

我也试过了:

 $client = new Client('https://api.buto.tv');
    $request = $client->get('v2/video/tag/');
    $request->setAuth('user', 'pass');
    $response = $request->send();

但我得到同样的错误。我输出了echo $request->getUrl();请求的网址,如果我将网址复制并粘贴到浏览器中,网址就可以了

1 个答案:

答案 0 :(得分:1)

我想你可能会错过一个斜线&#39; /&#39;在api.buto.tv之后,网址正在解析为https://api.buto.tvv2/video/tag/&#39;而不是&#39; https://api.buto.tv/v2/video/tag/&#39;。

$client = new Client('https://api.buto.tv/');
$request = $client->get('v2/video/tag/');
相关问题