-
-
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.
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 | |
$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