使用PHP上传中的Imgur API标题和说明

使用PHP上传中的Imgur API标题和说明,php,Php,我已经花了很多时间来了解Imgur的API函数是如何实现的,不幸的是没有成功 我有一个很好的PHP脚本将图像上传到Imgur,并再次将图像URL发回给我。当我上传时,我也希望能够在Imgur上给出图片标题和描述 但不管我怎么试,它都没能成功!你能告诉我它是怎么工作的吗?我不太理解Imgur的API指南 <html> <head> <title>Image Upload Using Imgur API</title> </head> &l

我已经花了很多时间来了解Imgur的API函数是如何实现的,不幸的是没有成功

我有一个很好的PHP脚本将图像上传到Imgur,并再次将图像URL发回给我。当我上传时,我也希望能够在Imgur上给出图片标题和描述

但不管我怎么试,它都没能成功!你能告诉我它是怎么工作的吗?我不太理解Imgur的API指南

<html>
<head>
<title>Image Upload Using Imgur API</title>
</head>
<body>
<div id="content" style="margin-top:10px;height:100%;">
<center><h1>Image Upload Using Imgur API</h1></center>
<form action="index.php" enctype="multipart/form-data" method="POST">
Choose Image : <input name="img" size="35" type="file"/>
Title : <input name="title" size="35" type="text"/><br/>
Description : <input name="description" size="35" type="text"/><br/>
<input type="submit" name="submit" value="Upload"/>
</form>
<?
if(isset($_POST['submit'])){
$img=$_FILES['img'];
if($img['name']==''){
echo "<h2>An Image Please.</h2>";
}else{
$filename = $img['tmp_name'];
$client_id="*****";//Your Client ID here
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
$pvars   = array('image': => base64_encode($data));
$timeout = 30;
$curl    = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID      ' .   $client_id));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);;
$out = curl_exec($curl);
curl_close ($curl);
$pms = json_decode($out,true);
$url=$pms['data']['link'];


if($url!=""){
 echo "<h2>Uploaded Without Any Problem</h2>";
 echo "<img src='$url'/><br>";
 echo $pms['data']['link']. "<br>";
 echo str_replace("http://","https://", "$url"); // dette er https versionen. 
 echo $pms['data']['id']. "<br>";
 echo $pms['data']['type']. "<br>";
 }else{
 echo "<h2>There's a Problem</h2>";
echo $pms['data']['error']['message'];
}
}
}
 ?>
  </div>

使用imgurapi上传图像
使用imgurapi上传图像
选择图像:
标题:
说明:

可以在这里找到图像的整个基本模型,包括一个JSON示例:您会发现API代码首先更容易在控制台程序中编写-只需获取任何旧图像,然后在没有HTML表单的情况下上载即可。但是我不明白如何发布标题可以在这里找到图像的整个基本模型,包括一个JSON示例:You'll find API首先,在控制台程序中编写代码更容易——只需获取任何旧图像,然后在没有HTML表单的情况下上传即可。但我不知道如何发布标题