Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating ticket with attachments giving strange error #53

Open
Zain-ulHassan opened this issue Jun 1, 2018 · 0 comments
Open

Creating ticket with attachments giving strange error #53

Zain-ulHassan opened this issue Jun 1, 2018 · 0 comments

Comments

@Zain-ulHassan
Copy link

Zain-ulHassan commented Jun 1, 2018

i am using PHP Version 7.2.2 and i am following this document https://github.com/freshdesk/fresh-samples/blob/master/PHP/create_ticket_with_attachment.php to create a ticket with attachment but i am getting this error Error, HTTP Status Code : 0 Headers are Response are .

Here is my code below

$ticket_payload = array(
'email' => $email,
'subject' => 'test',
'description' => 'testing description content',
'priority' => 2,
'status' => 2,
'attachments[]' => curl_file_create("data/butterfly.png", "image/png", "butterfly.png"),
);

$url = "https://$yourdomain.freshdesk.com/api/v2/tickets"; $ch = curl_init($url);`

`$header[] = "Content-type: multipart/form-data";`

`curl_setopt($ch, CURLOPT_POST, false);`
`curl_setopt($ch, CURLOPT_HEADER, true);`
`curl_setopt($ch, CURLOPT_HTTPHEADER, $header);`
`curl_setopt($ch, CURLOPT_USERPWD, "$api_key:$password");`
`curl_setopt($ch, CURLOPT_POSTFIELDS, $ticket_payload);`
`curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);`

$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);

am i doing something wrong ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant