使用delphi将图像上传到imageshack
我有 API 密钥并阅读了他们网站上的稀疏文档,但仍然无法使其正常工作,因此如果有人有任何可以分享的示例,那就太好了。我不需要担心视频或任何花哨的东西,只需简单上传返回信息即可满足我的需求。
uses IdHttp;
function PostData:string;
var
url: string;
text: string;
http: TIDHttp;
valid: boolean;
param: TStringList;
begin
http := TIDHttp.Create(nil);
http.HandleRedirects := true;
http.ReadTimeout := 5000;
param := TStringList.create;
param.Clear;
param.Add('fileupload=c:\image.png');
param.Add('key=MY_API_KEY');
param.Add('tags=tag1,tag2');
valid := true;
url := 'http://www.imageshack.us/upload_api.php';
try
text := http.Post(url, param);
except
valid := false;
end;
if valid then
PostData := text
else
PostData := '';
end;
谢谢。 凯文
I have the API key and read the sparse documentation on their site, but still having trouble getting this to work so if anyone has any examples they could share then that would be great. I do not need to worry about videos or anything fancy, just a simple upload with the return information will suit my needs.
uses IdHttp;
function PostData:string;
var
url: string;
text: string;
http: TIDHttp;
valid: boolean;
param: TStringList;
begin
http := TIDHttp.Create(nil);
http.HandleRedirects := true;
http.ReadTimeout := 5000;
param := TStringList.create;
param.Clear;
param.Add('fileupload=c:\image.png');
param.Add('key=MY_API_KEY');
param.Add('tags=tag1,tag2');
valid := true;
url := 'http://www.imageshack.us/upload_api.php';
try
text := http.Post(url, param);
except
valid := false;
end;
if valid then
PostData := text
else
PostData := '';
end;
Thx.
Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
昨晚我几乎做了同样的事情。谢谢。
I pretty much did the exact same thing last nite. Thx tho.