【发布时间】:2017-06-01 03:19:06
【问题描述】:
我第一次使用 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"]}}'
我在 curl 请求的 -u 中遇到问题。
I have written this code.
$response = $client->post($url, [
'headers' => ['Content-type' => 'application/json'],
'auth' => ['username:password'],
'json' => [
'username' => 'test'
],
]);
$results = $response->json();
我试过this但无法调用API
任何建议或帮助。
【问题讨论】: