Skip to content

Instantly share code, notes, and snippets.

@wouterds
Created January 7, 2015 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wouterds/62d0b8c74781743770d6 to your computer and use it in GitHub Desktop.
Save wouterds/62d0b8c74781743770d6 to your computer and use it in GitHub Desktop.
<?php
$client_id = "";
$image = file_get_contents("tmp.png");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => base64_encode($image)));
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
imagedestroy($img);
unlink("tmp.png");
die($reply->data->link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment