Skip to content

Instantly share code, notes, and snippets.

@hamada147
Forked from scottydelta/imgur.php
Last active September 21, 2015 08:34
Show Gist options
  • Save hamada147/c5f625bbcb64f17df75f to your computer and use it in GitHub Desktop.
Save hamada147/c5f625bbcb64f17df75f to your computer and use it in GitHub Desktop.
A php script to upload images to Imgur anonymously using Imguy API V3. The input is an image and Output is a direct ink.
<?php
$client_id = 'xxxxxxxx';
$file = file_get_contents("test-image.png");
$url = 'https://api.imgur.com/3/image.json';
$headers = array("Authorization: Client-ID $client_id");
$pvars = array('image' => base64_encode($file));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL=> $url,
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $pvars
));
$json_returned = curl_exec($curl); // blank response
echo "Result: " . $json_returned ;
curl_close ($curl);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment