Created
December 15, 2013 11:37
-
-
Save scottydelta/7971955 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 hidden or 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
it always return a blank response
why???
and i get an error Trying to get property of non-object
which means that the curl_exec() failed to run
so any ideas what's going wrong??
Edit 1:
So i manged to make it work through this line of code
which over look the SSL verification is there is any other way
Edit 2:
the php code
the html code