delphipastebin

How do I list Pastebin pastes created by a user in Delphi?


I am a beginner in Delphi (I use Delphi 2010 because of school) and I am trying to get an output textfile with a list of pastes that a pastebin user has created, but I am not exactly sure how to do it. On Pastebin.com (PastebinAPI), they explain how the API works, but I can't get it working on Delphi.

Here is what I have coded so far (I blurred out my details):

procedure TfrmLogin.imgLoginButtonClick(Sender: TObject);
var
  sSource, sAPI_Dev_Key, sAPI_User_Key, sAPI_Results_Limit, sAPI_Option,
    sListPasteLink: String;
begin

  sSource := 'https://pastebin.com/api/api_post.php/';
  sAPI_Dev_Key := 'xxxxxxxxxxxxxxxxxxxxxxxx/';
  sAPI_User_Key := 'xxxxxxxxxxxxxxxxxxxxxxx/';
  sAPI_Results_Limit := '1000/';
  sAPI_Option := 'list';

  sListPasteLink := sSource + sAPI_Dev_Key + sAPI_User_Key +
    sAPI_Results_Limit + sAPI_Option;
end;

I am not sure what to do after this, how do I POST this generated link in Delphi to get the list of pastes created?

I tried copying the generated link and pasting it in my web browser, but Pastebin says This page has been removed!

Any help would be appreciated, thank you


Solution

  • Here is an example. Drop a TButton, a TMemo, a TIdHTTP and a TIdSSLIOHandlerSocketOpenSSL on a form. You will also need to copy libeay32.dll and ssleay32.dll into your application directory (they are provided somehere in the directory where Delphi was installed).

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Params: TStringList;
    begin
      Params := TStringList.Create;
      Params.Add('api_dev_key=*****');
      Params.Add('api_user_key=*****');
      Params.Add('api_option=list');
      try
        IdSSLIOHandlerSocketOpenSSL1.SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2];
        IdHTTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
        Memo1.Text := IdHTTP1.Post('https://pastebin.com/api/api_post.php', Params);
      finally
        Params.Free;
      end;
    end;