我有以下匿名上传的代码就好了,但我似乎无法弄清楚我的生活如何登录我的帐户上传。我发现你需要使用OAuth并且需要每小时刷新你的令牌,但这是我似乎无法理解的东西,因为我不知道从哪里开始。
$handle = fopen($file_tmp, "r");
$data = fread($handle, $file_size);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => base64_encode($data)));
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
$url = $reply->data->link;