我有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;
谢谢.
凯文
procedure TForm1.Button1Click(Sender: TObject); var MPData: TIdMultiPartFormDataStream; sResponse: string; begin MPData := TIdMultiPartFormDataStream.Create; MPData.AddFile('fileupload','c:\image.png','image/png'); MPData.AddFormField('tags','testfile,flyasia'); MPData.AddFormField('public','no'); MPData.AddFormField('key','API_KEY_HERE'); sResponse := IdHTTP1.Post('http://www.imageshack.us/upload_api.php', MPData); MPData.Free; Memo1.Text := sResponse; end;