My requirement is to give customer option to upload image & this image needs to be send to zen desk. Do I need to upload the image on some server before using the upload function of zen desk.
Following is the code i m trying, but its not working
$uri = 'https://company.zendesk.com/api/v2/uploads.json?filename=image.jpg';
$target_file = $_FILES['file']['tmp_name'];
$fildata = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_USERPWD, "xxxx@test.com/token:xxxxx");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/binary'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fildata);
curl_setopt($ch, CURLOPT_INFILE, $file);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$output = curl_exec($ch);
Hey Shweta,
If you go to the admin panel then down to settings/customers do you see that 'Require authentication for request and uploads APIs' is enabled?
Thanks!
Have a wonderful day!
Eric Nelson | Manager - Developer Advocacy