I'm trying to use the gfycat API to create a gfycat with a file upload through curl with php but it doesn't work and var_dump($response) gives me bool(false).
My Code:
$file_path = $target_dir.$newfilename;
$cFile = curl_file_create($file_path);
$data = array(
"file" => $cFile,
);
$target_url = "https://filedrop.gfycat.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: multipart/form-data"
));
$response = curl_exec($ch);
var_dump($response); // bool(false) here
curl_close($ch);
Help would be really appreciated. Thanks.