I want to use the RapidShare API in my project,but I don't know how I can call it then receive the result.
I use Delphi 2009.
I want to use the RapidShare API in my project,but I don't know how I can call it then receive the result.
I use Delphi 2009.
All you have to do is make a HTTP request and fetch the result.
Try this link to see how it works: getapicpu_v1
Here you can find which calls you can make: http://images.rapidshare.com/apidoc.txt
The code below prints this:
getapicpu_v1: 0,60000
nextuploadserver_v1: 669
FetchHTML() is just a helper function to retrieve the result of an HTTP request. If you use a proxy, it'll automatically use the one that you've configured in Internet explorer.
program RapidShareTest;
{$APPTYPE CONSOLE}
uses
SysUtils, WinInet;
function FetchHTML(url:string):AnsiString;
var
databuffer : array[0..4095] of AnsiChar;
ResStr : AnsiString;
hSession, hfile: hInternet;
dwindex,dwcodelen,dwread,dwNumber:cardinal;
dwcode : array[1..20] of char;
res : pAnsiChar;
Str : pAnsiChar;
begin
ResStr := '';
if pos('http://',lowercase(url))=0 then
url := 'http://'+url;
hSession := InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG,nil, nil, 0);
try
if assigned(hsession) then
begin
hfile := InternetOpenUrl(hsession,pchar(url),nil,0,INTERNET_FLAG_RELOAD, 0);
dwIndex := 0;
dwCodeLen := 10;
HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE,@dwcode, dwcodeLen, dwIndex);
res := pAnsiChar(@dwcode);
dwNumber := sizeof(databuffer)-1;
while (InternetReadfile(hfile,@databuffer,dwNumber,DwRead)) do
begin
if dwRead =0 then
break;
databuffer[dwread]:=#0;
Str := pAnsiChar(@databuffer);
resStr := resStr + Str;
end;
if assigned(hfile) then
InternetCloseHandle(hfile);
end;
finally
InternetCloseHandle(hsession);
end;
Result := resStr;
end;
begin
Writeln('getapicpu_v1: ');
WriteLn(FetchHTML('http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=getapicpu_v1'));
WriteLn;
Writeln('nextuploadserver_v1: ');
WriteLn(FetchHTML('http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=nextuploadserver_v1'));
WriteLn;
ReadLn;
end.