Skip to content

Instantly share code, notes, and snippets.

@JasvinderSingh1
Created August 9, 2019 09:18
Show Gist options
  • Save JasvinderSingh1/f113f8e22c0d4d79345560270f4abefc to your computer and use it in GitHub Desktop.
Save JasvinderSingh1/f113f8e22c0d4d79345560270f4abefc to your computer and use it in GitHub Desktop.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api.resmush.it/ws.php?qlty=80&img=http://freetouse.com.dev.ceptiv.net/track-cover/thumb/Vlad-Gluschenko-Lean-On.jpg');
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$result = curl_error($ch);
}
curl_close ($ch);
//
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//var_dump($result);
print_r($result);
$someObject = json_decode($result);
$img=file_get_contents($someObject->dest);
$ch2 = curl_init($someObject->dest);
$fp = fopen("Vlad-Gluschenko-Lean-On.jpg", 'wb');
curl_setopt($ch2, CURLOPT_FILE, $fp);
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_exec($ch2);
$result2 = curl_exec($ch2);
if (curl_errno($ch2)) {
$result2 = curl_error($ch2);
}
curl_close($ch2);
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment