Skip to content

Instantly share code, notes, and snippets.

@henriqueboaventura
Created July 28, 2016 20:27
Show Gist options
  • Save henriqueboaventura/f4a4b4bc92407f3bea8f2f8c0b82ac9e to your computer and use it in GitHub Desktop.
Save henriqueboaventura/f4a4b4bc92407f3bea8f2f8c0b82ac9e to your computer and use it in GitHub Desktop.
<?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');
Copy link

ghost commented Jul 28, 2016

gif maneiro kkk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment