Forked from tim-peterson/Docverter PHP-CURL example
Created
November 28, 2019 12:57
-
-
Save mattimatti/4e8d6f66979dede9c32ecf2d0382ec5c to your computer and use it in GitHub Desktop.
Docverter PHP-CURL example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//set POST variables | |
$url = 'http://c.docverter.com/convert'; | |
$fields = array('from' => 'markdown', | |
'to' => 'pdf', | |
'input_files[]' => "@/".realpath('markdown.md').";type=text/x-markdown; charset=UTF-8" | |
); | |
//open connection | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data")); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
//execute post | |
$result = curl_exec($ch); | |
//close connection | |
curl_close($ch); | |
//write to file | |
$fp = fopen('uploads/result.pdf', 'w'); | |
fwrite($fp, $result); | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment