using imgur api v3 to upload images anonymously using php

后端 未结 3 2044
爱一瞬间的悲伤
爱一瞬间的悲伤 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:04

    Sending the client_id in a post variable is the problem. It needs to be sent in the request header. Also, you're requesting a JSON response, but trying to parse it as XML.

     base64_encode($image)));
    
    $reply = curl_exec($ch);
    curl_close($ch);
    
    $reply = json_decode($reply);
    printf('', $reply->data->link);
    

    update 1

    Live functional example with and source based on this code with debug output.

提交回复
热议问题