using imgur api v3 to upload images anonymously using php

后端 未结 3 2046
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 00:23

I am planning to upload images to imgur anonymously using its api, i registered my application in the anonymous upload category and got client id and client secret, How to u

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 01:09

    found the error, I need to send authorization details as header, eg code

     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); 
    
    ?>
    

提交回复
热议问题