zippoxer Posted December 3, 2011 Share Posted December 3, 2011 (edited) var PasteBinHttpClient: Integer; PasteBinDevKey, PasteBinUserKey: String; procedure PasteBinSetup(DevKey: String); begin PasteBinDevKey := DevKey; PasteBinHttpClient := InitializeHTTPClient(False, False); end; function PasteBinSuccessful(Response: String): Boolean; begin Result := (Length(Response) > 0) and not StartsWith('Bad', Response); end; function PasteBinLogin(Name, Password: String): Boolean; var Response: String; begin ClearPostData(PasteBinHttpClient); AddPostVariable(PasteBinHttpClient, 'api_dev_key', PasteBinDevKey); AddPostVariable(PasteBinHttpClient, 'api_user_name', Name); AddPostVariable(PasteBinHttpClient, 'api_user_password', Password); Response := PostHTTPPageEx(PasteBinHttpClient, 'http://pastebin.com/api/api_login.php'); if PasteBinSuccessful(Response) then begin PasteBinUserKey := Response; Result := True; end; end; procedure PasteBinLogout; begin PasteBinUserKey := ''; end; function PasteBinPostEx(Code, Name, ExpireDate, Format: String; IsPrivate: Boolean; out Url: String): Boolean; var IsPrivateStr, Response: String; begin IsPrivateStr := '0'; if IsPrivate then IsPrivateStr := '1'; ClearPostData(PasteBinHttpClient); AddPostVariable(PasteBinHttpClient, 'api_dev_key', PasteBinDevKey); AddPostVariable(PasteBinHttpClient, 'api_user_key', PasteBinUserKey); AddPostVariable(PasteBinHttpClient, 'api_option', 'paste'); AddPostVariable(PasteBinHttpClient, 'api_paste_code', Code); AddPostVariable(PasteBinHttpClient, 'api_paste_name', Name); AddPostVariable(PasteBinHttpClient, 'api_paste_expire_date', ExpireDate); AddPostVariable(PasteBinHttpClient, 'api_paste_format', Format); AddPostVariable(PasteBinHttpClient, 'api_paste_private', IsPrivateStr); Response := PostHTTPPageEx(PasteBinHttpClient, 'http://pastebin.com/api/api_post.php'); if PasteBinSuccessful(Response) then begin Url := Response; Result := True; end; end; // Posts a paste that never expires, has no format and is not private. function PasteBinPost(Code: String; out Url: String): Boolean; begin Result := PasteBinPostEx(Code, '', 'N', 'text', False, Url); end; procedure PasteBinTest; var Url: String; begin PasteBinSetup('89fd7c77653a7e05ab04010a0aba000a'); if PasteBinLogin('ScarStatistics', 'service') then begin WriteLn('Logged in to pastebin.'); if PasteBinPostEx('"omfg"', 'I have 10 minutes left to live!', '10M', 'php', True, Url) then WriteLn('Successfully posted that: ' + Url) else WriteLn('Failed to post.'); end else WriteLn('Are you kidding me?'); end; Usage sample is in the PasteBinTest procedure. You can use it to submit statistics Edited December 3, 2011 by zippoxer documentation Quote Link to comment Share on other sites More sharing options...
FHannes Posted December 3, 2011 Share Posted December 3, 2011 Heh, that's nice Quote Link to comment Share on other sites More sharing options...
Main Posted December 14, 2011 Share Posted December 14, 2011 Cool you should make it save as a text file aswell if scar crashed or something, still uber uber nice job:p Quote Link to comment Share on other sites More sharing options...
Wanted Posted December 14, 2011 Share Posted December 14, 2011 This is pretty cool, considering it for a misc file in OSI Quote Link to comment Share on other sites More sharing options...