Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading a file to imgur using PHP Imgurv3 API
    text
    copied!<p>I writing a webapp which uploads images to imgur directly. Since all older version of their APIs have been deprecated i am forced to use v3 of their APIs. Unfortunately I am unable to get the API to work. I am using curl to access the API.</p> <pre><code>$pvars = array('image' =&gt; base64_encode($data)); $timeout = 30; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/upload'); curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID xxxxxxa61xxxxxx')); $xml = curl_exec($curl); $xmlsimple = new SimpleXMLElement($xml); print gettype($xml)."&lt;hr&gt;"; echo '&lt;img height="180" src="'; echo $xmlsimple-&gt;links-&gt;original; echo '"&gt;'; curl_close ($curl); </code></pre> <p>The "Xml" variable always return as "false", no server error is displayed. Can someone guide me to what I am doing wrong ? Unfortunately I am also unable to find any proper example in the documentation nor around to guide me.</p> <p>I've just tried the code from another question on stack overflow but I am still getting the same problem.</p> <pre><code> var_dump(base64_encode($data)); echo "&lt;hr&gt;"; $client_id = "xxxxxxa61xxxxxx"; $url = 'https://api.imgur.com/3/image.json'; $headers = array("Authorization: Client-ID $client_id"); $pvars = array('image' =&gt; base64_encode($data)); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL=&gt; $url, CURLOPT_TIMEOUT =&gt; 30, CURLOPT_POST =&gt; 1, CURLOPT_RETURNTRANSFER =&gt; 1, CURLOPT_HTTPHEADER =&gt; $headers, CURLOPT_POSTFIELDS =&gt; $pvars )); $json_returned = curl_exec($curl); // blank response print_r(curl_getinfo($curl)); echo "&lt;hr&gt;"; echo "Result: " . $json_returned ; echo "&lt;hr&gt;"; var_dump($json_returned); echo "&lt;hr&gt;"; curl_close ($curl); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload