【发布时间】:2015-06-01 05:57:33
【问题描述】:
我正在尝试将 curl 转换为 guzzle 请求,这是 curl 请求。
curl https://{subdomain}.zendesk.com/api/v2/tickets.json \
-d '{"ticket": {"subject": "My printer is on fire!", "comment": { "body": "The smoke is very colorful." }}}' \
-H "Content-Type: application/json" -v -u {email_address}:{password} -X POST
这是 JSON 部分:
{
"ticket": {
"requester": {
"name": "The Customer",
"email": "thecustomer@domain.com"
},
"subject": "My printer is on fire!",
"comment": {
"body": "The smoke is very colorful."
}
}
}
这是我损坏的 PHP 代码。
$client = new GuzzleHttp\Client();
$res = $client->post('https://midnetworkshelp.zendesk.com/api/v2/tickets/tickets.json', [
'query' => [
'ticket' => ['subject' => 'My print is on Fire'], [
'comment' => [
'body' => 'The smoke is very colorful'] ], 'auth' => ['email', 'Password']]);
echo $res->getBody();
我不断获得用户未经授权的访问权限,但是当我触发 curl 命令时,它可以正常工作。
知道我在这里可能缺少什么吗?
谢谢
【问题讨论】: