0
我的請求與ajax一起工作正常,但是當我試圖用guzzle重新創建場景時失敗。我得到了一個400壞迴應。我有一種感覺,我可能會在槍口參數中設置錯誤嗎?這是我第一次使用這個。Guzzle POST請求php vs Ajax
阿賈克斯
var usernameV5 = '108357166';
var passwordV5 = '1234';
var data = {
'type':'base64',
'value':btoa(usernameV5 + ":" + passwordV5),
'namespace':'https://somelink/customers'
};
data = JSON.stringify(data);
$.ajax({
'type':'POST',
'headers':{'Content-Type':'application/json'},
'url':'cantshow.com',
'data':data,
'success':function (result) {
},
'error':function() {
}
});
狂飲
$username = '108357166';
$password = '1234';
$client = new \GuzzleHttp\Client();
$result = $client->post('cantshow.com', [
'headers' => [
'Content-Type' => 'application/json'
],
'data' => [
'type' => 'base64',
'value' => base64_encode("'".$username.":".$password."'"),
'namespace' => 'https://somelink/customers'
]
])->getBody();
狂飲什麼版本的? – Kyslik
版本6.2.2。 –