Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获得;提供的用户凭据无效";使用Guzzle PHP发送请求时_Php_Postman_Guzzle - Fatal编程技术网

获得;提供的用户凭据无效";使用Guzzle PHP发送请求时

获得;提供的用户凭据无效";使用Guzzle PHP发送请求时,php,postman,guzzle,Php,Postman,Guzzle,我正在向一个端点发送完全相同的请求,该端点使用Guzzle PHP和Chrome的Postman扩展 当用邮递员发送请求时,我确实收到了响应,但是当我用Guzzle发送相同的请求时,我得到了“提供的用户凭据无效” 我的身份验证类型为Basic,并为两个应用程序提供相同的用户名/密码。以下是我用于guzzle的代码: $credentials = [$client->api_username, $client->decrypted_password, 'basic'];

我正在向一个端点发送完全相同的请求,该端点使用Guzzle PHP和Chrome的Postman扩展

当用邮递员发送请求时,我确实收到了响应,但是当我用Guzzle发送相同的请求时,我得到了“提供的用户凭据无效”

我的身份验证类型为Basic,并为两个应用程序提供相同的用户名/密码。以下是我用于guzzle的代码:

    $credentials = [$client->api_username, $client->decrypted_password, 'basic'];

    $result = $this->client->get($fullUrl, [
       'auth' => $credentials
    ]);

我已转储凭据-它是正确的数组。我已经仔细检查过了。有趣的是,当我试图为同一个端点发送另一个用户的请求时,我确实收到了正确的响应,这让我想到,我可能在凭证中有输入错误-但我已重新检查-甚至从邮递员处粘贴副本-仍然无法收到响应://

是否愿意将变量
$credentials
作为数据共享? 如果需要,请尝试下面的代码,该代码经过测试并正常工作:

$client  = new Client();
$this->results = $client->request('GET/POST', $uri, [
  'debug' => true,
  'query'   => $arguments,
  'auth'    => [$username, $password],
  'verify'  => false
])->getBody();
如果您询问其他参数,如
verify
,此属性会告诉guzzle禁用证书验证

阅读如下:


有关
auth

的更多信息,请比较邮递员和Guzzle提供的
身份验证
标题?如果您从Guzzle获得异常,您可以像
$exception->getRequest()->getHeader('Authentication')

尝试“验证”=>false一样获得它,仍然是相同的问题:/。当设置debug为true-get时,会出现与CURL相关的错误,我认为这是因为我在windows计算机上。guzzle错误消息是“提供了无效的用户凭据”,尽管我可以在通过postmanthy发送时使用相同的消息。我认为这个问题在某种程度上与Guzzle的SSL有关