我正在尝试post
使用Illuminate\Support\Facades\Http
.
我的请求 :
$response = Http::post(
$this->api.'/auth',
[
'auth' => [
'username' => $this->username,
'password' => $this->password
]
]
)->json('response');
While api
, username
andpassword
被设置在一个__construct
方法中。
这个请求在邮递员中运行良好。但是当我在 php 服务器上运行它时,我得到一个null
. 我深入研究了回复,发现以下内容:
Illuminate\Http\Client\Response {#2741 ▼
#response: GuzzleHttp\Psr7\Response {#2766 ▼
-reasonPhrase: "Not Acceptable"
-statusCode: 406
-headers: array:5 [▼
"Server" => array:1 [▶]
"Date" => array:1 [▶]
"Content-Type" => array:1 [▶]
"Content-Length" => array:1 [▶]
"Connection" => array:1 [▶]
]
-headerNames: array:5 [▼
"server" => "Server"
"date" => "Date"
"content-type" => "Content-Type"
"content-length" => "Content-Length"
"connection" => "Connection"
]
-protocol: "1.1"
-stream: GuzzleHttp\Psr7\Stream {#2765 ▼
-stream: stream resource @28 ▶}
-size: null
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}
}
你知道如何解决这个问题吗?