我正在尝试使用php curl中的freshdesk API创建一张Freshdesk票。 按照此文档链接https://github.com/freshdesk/fresh-samples/tree/master/php_samples 但它没有创建票证
<?php
$fd_domain = "http://test.freshdesk.com";
$token = "apikey";
$password = "xxx";
$email = "aaa@bbb.com";
$data = array(
"helpdesk_ticket" => array(
"description" => "Some details on the issue ...",
"subject" => "TEST Support needed..",
"email" => "tom@outerspace.com",
"priority" => 1,
"status" => 2
),
"cc_emails" => "ram@freshdesk.com,diana@freshdesk.com"
);
$json_body = json_encode($data, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
$header[] = "Content-type: application/json";
$connection = curl_init("$fd_domain/helpdesk/tickets.json");
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_HTTPHEADER, $header);
curl_setopt($connection, CURLOPT_HEADER, false);
curl_setopt($connection, CURLOPT_USERPWD, "$email:$password");
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_POSTFIELDS, $json_body);
curl_setopt($connection, CURLOPT_VERBOSE, 1);
$response = curl_exec($connection);
echo $response;
?>
当我在终端中运行此文件为php file.php但是票证没有运行,我得到以下控制台结果 但我不确定发生了什么。
* Hostname was NOT found in DNS cache
* Trying 107.22.197.253...
* Connected to test.freshdesk.com (107.22.197.253) port 80 (#0)
* Server auth using Basic with user 'aaa@bbb.com'
> POST /helpdesk/tickets.json HTTP/1.1
Authorization: Basic bW9oYW5Ad2h5YWJsZS5jb206bW9oYW4xMjM=
Host: test.freshdesk.com
Accept: */*
Content-type: application/json
Content-Length: 274
* upload completely sent off: 274 out of 274 bytes
< HTTP/1.1 302 Found
< Cache-Control: no-cache
< Content-Type: text/html; charset=utf-8
< Location: https://test.freshdesk.com/helpdesk/tickets.json
< Set-Cookie: helpdesk_node_session=0fbdb53a62fff9b78f57d069a7abfde86bef1e16eefa8710dbcadb99a1723a3a42affa906dd23ceb6e77f20f0a0e703a2cb6d3423cb94ec074f0006dadfe4b02; path=/
< Set-Cookie: _helpkit_session=BAh7CDoPc2Vzc2lvbl9pZCIlMzdmNGI4ZDZkZWMxNmRhNDBkYWI1ZTFiODU2NDFkODhJIhV1c2VyX2NyZWRlbnRpYWxzBjoGRUZJIgGAZmYxMmExZWJjZGFiMTlkMjgxYjlkYmI0NjIwZjdhMjFlYTgxM2YyZWE5M2UzYTk0MTlhYzBhNDA2M2QyMzEwNTdmNDQ4NjVjYmE1MjA1ZjU2ODUzNGI2ZGQ4NTExZjljZGUyZGQxNzViMzNjMzhkZTYxMTc1MDRkMWE2MGMyOTEGOwZUSSIYdXNlcl9jcmVkZW50aWFsc19pZAY7BkZsKwj%2B0TIqAQA%3D--fdc65abdf0bdcf0c38db4837f05b19050ef1a2f0; path=/; HttpOnly
< Status: 302
< X-Runtime: 25
< Content-Length: 117
< Connection: keep-alive
<
* Connection #0 to host test.freshdesk.com left intact
<html><body>You are being <a href="https://test.freshdesk.com/helpdesk/tickets.json">redirected</a>.</body></html>
请帮助我