Created
July 28, 2016 20:27
-
-
Save henriqueboaventura/f4a4b4bc92407f3bea8f2f8c0b82ac9e to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
//set POST variables | |
$url = 'http://api.convertio.co/convert'; | |
$fields = array( | |
'apikey' => urlencode('5ec45248e15564f823de2b4c9be34214'), | |
'file' => urlencode("http://zaxy.com.br/public/upload/exports/gif.gif"), | |
'outputformat' => urlencode('mp4'), | |
); | |
//url-ify the data for the POST | |
$fields_string = '{"apikey": "5ec45248e15564f823de2b4c9be34214", "file":"http://zaxy.com.br/public/upload/exports/gif.gif", "outputformat":"mp4"}'; | |
//open connection | |
$ch = curl_init(); | |
//set the url, number of POST vars, POST data | |
curl_setopt($ch,CURLOPT_URL, $url); | |
curl_setopt($ch,CURLOPT_POST, count($fields)); | |
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); | |
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE); | |
//execute post | |
$result = json_decode(curl_exec($ch)); | |
echo "- chamada de conversão " .date('Y-m-d H:i:s'). " \n"; | |
$process = TRUE; | |
while($process){ | |
$ch2 = curl_init(); | |
//set the url, number of POST vars, POST data | |
curl_setopt($ch2,CURLOPT_URL, 'http://api.convertio.co/convert/'.$result->data->id.'/status'); | |
//curl_setopt($ch2,CURLOPT_POST, count($fields)); | |
//curl_setopt($ch2,CURLOPT_POSTFIELDS, $fields_string); | |
curl_setopt($ch2,CURLOPT_RETURNTRANSFER, TRUE); | |
$status = json_decode(curl_exec($ch2)); | |
if($status->data->step == 'finish') { | |
$process = FALSE; | |
} | |
echo "- chamada de status " .date('Y-m-d H:i:s'). " \n"; | |
curl_close($ch2); | |
sleep(1); | |
} | |
curl_close($ch); | |
copy($status->data->output->url, 'meu_gif.mp4'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gif maneiro kkk