我第一次使用guzzle.任何人都可以告诉我如何为此请求编写Guzzle电话.
curl -X POST -u username:password -H "Content-Type: application/json" https://xyz/api/v1/accounts.json -d '{"user":{"username":"test","password":"xyz","first_name":"test","last_name":"test","email":"test@test.com","roles":["Administrator"]}}'
Run Code Online (Sandbox Code Playgroud)
我在卷曲请求的-u中遇到问题.
I have written this code.
$response = $client->post($url, [
'headers' => ['Content-type' => 'application/json'],
'auth' => ['username:password'],
'json' => [
'username' => 'test'
],
]);
$results = $response->json();
Run Code Online (Sandbox Code Playgroud)
我试过这个但无法调用API
任何建议或帮助.