Results 1 to 10 of 10
  1. #1
    Raydenman's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Location
    Italy
    Posts
    261
    Reputation
    10
    Thanks
    810
    My Mood
    Amused

    Post Pastebin Paste Maker Class (C#/VB.NET)

    Hi guys, today I finished to code some classes to make a Paste on Pastebin. I used the API to simplify my job.
    Today I released the class to an italian forum, now let's post here

    VB.NET Version
    Code:
    Imports System.Collections.Specialized
    Imports System.Net
    Imports System.Text
    
    Public Class Paste
    
        Dim _devkey As String
        Dim _username As String
        Dim _userpassword As String
        Dim _PasteCode As String
        Dim _PasteName As String
        Dim _Syntax As String
        Dim _ExpireDate As String
        Dim _PasteExposure As Integer
        Dim ukey As String
        Sub New(ByVal Key As String, ByVal username As String, ByVal password As String, ByVal PasteCode As String, _
                ByVal PasteName As String, ByVal PasteExposure As Integer, ByVal SyntaxHighlighting As String, _
                ByVal ExpireDate As String)
            _devkey = Key
            _username = username
            _userpassword = password
            _PasteCode = PasteCode
            _PasteName = PasteName
            _PasteExposure = PasteExposure
            _Syntax = SyntaxHighlighting
            _ExpireDate = ExpireDate
        End Sub
    
        Public Function Start() As String
            Dim chiavi As New NameValueCollection()
            chiavi.Add("api_dev_key", _devkey)
            chiavi.Add("api_user_name", _username)
            chiavi.Add("api_user_password", _userpassword)
    
            Dim wClient As New WebClient()
            Dim risposta As String = Encoding.UTF8.GetString(wClient.UploadValues("https://pastebin.com/api/api_login.php", chiavi))
    
            If risposta.ToLower.Contains("bad api request") Then
                MessageBox.Show("Login failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return "ERROR"
            Else
                ukey = risposta
                Try
                    Dim output As String = MakePaste() 'Restituisce una stringa
                    Process.Start(output)
                    Return "SUCCESS"
                Catch Ex As Exception
                    MessageBox.Show("Exception: " & Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Return "ERROR"
                End Try
            End If
        End Function
    
        Public Function MakePaste() As String
            If ukey = "" Then Return "ERROR"
    
            Dim chiavi As New NameValueCollection()
            chiavi.Add("api_dev_key", _devkey)
            chiavi.Add("api_user_key", ukey)
            chiavi.Add("api_option", "paste")
            chiavi.Add("api_paste_code", _PasteCode)
            chiavi.Add("api_paste_name", _PasteName)
            chiavi.Add("api_paste_format", _Syntax)
            chiavi.Add("api_paste_private", _PasteExposure)
            chiavi.Add("api_paste_expire_date", "N")
    
            Dim wc As New WebClient()
            Dim Risultato As String = ""
            Dim Risposta As String = Encoding.UTF8.GetString(wc.UploadValues( _
                                                             "https://pastebin.com/api/api_post.php", chiavi))
    
            If Risposta.ToLower.Contains("bad api request") Then
                ' Key non valida
            Else
                Risultato = Risposta
            End If
            Return Risultato
        End Function
    End Class
    C# Version
    Code:
    using System.Collections.Specialized;
    using System.Net;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System;
    
    public class Paste
    {
    
        private string _devkey;
        private string _username;
        private string _userpassword;
        private string _PasteCode;
        private string _PasteName;
        private string _Syntax;
        private string _ExpireDate;
        private int _PasteExposure;
        private string ukey;
        public Paste(string Key, string username, string password, string PasteCode, string PasteName, int PasteExposure, string SyntaxHighlighting, string ExpireDate)
        {
            _devkey = Key;
            _username = username;
            _userpassword = password;
            _PasteCode = PasteCode;
            _PasteName = PasteName;
            _PasteExposure = PasteExposure;
            _Syntax = SyntaxHighlighting;
            _ExpireDate = ExpireDate;
        }
    
        public string Start()
        {
            NameValueCollection chiavi = new NameValueCollection();
            chiavi.Add("api_dev_key", _devkey);
            chiavi.Add("api_user_name", _username);
            chiavi.Add("api_user_password", _userpassword);
    
            WebClient wClient = new WebClient();
            string risposta = Encoding.UTF8.GetString(wClient.UploadValues("https://pastebin.com/api/api_login.php", chiavi));
    
            if (risposta.ToLower().Contains("bad api request"))
            {
                MessageBox.Show("Login failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return "ERROR";
            }
            else
            {
                ukey = risposta;
                try
                {
                    string output = MakePaste();
                    Process.Start(output);
                    return "SUCCESS";
                }
                catch (Exception Ex)
                {
                    MessageBox.Show("Exception: " + Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return "ERROR";
                }
            }
        }
    
        public string MakePaste()
        {
            if (ukey == "")
            {
                return "ERROR";
            }
    
            NameValueCollection chiavi = new NameValueCollection();
            chiavi.Add("api_dev_key", _devkey);
            chiavi.Add("api_user_key", ukey);
            chiavi.Add("api_option", "paste");
            chiavi.Add("api_paste_code", _PasteCode);
            chiavi.Add("api_paste_name", _PasteName);
            chiavi.Add("api_paste_format", _Syntax);
            chiavi.Add("api_paste_private", _PasteExposure.ToString());
            chiavi.Add("api_paste_expire_date", "N");
    
            WebClient wc = new WebClient();
            string Risultato = "";
            string Risposta = Encoding.UTF8.GetString(wc.UploadValues("https://pastebin.com/api/api_post.php", chiavi));
    
            if (Risposta.ToLower().Contains("bad api request"))
            {
                
            }
            else
            {
                Risultato = Risposta;
            }
    
            return Risultato;
        }
    }
    Now let's create an instance of the class. On the button "Create paste" put:
    VB.NET
    Code:
    Dim Maker As New Paste("your pastebin API", "your pastebin username", "your pastebin password", txtCode.Text, _
                                   "paste name", 1, "php", "N")
            ' Parameter ExpireDate> N= Never // 1M= 1 Month // 10M= 10 Minutes e così via, etc...
            ' Parameter PasteExposure> 0= Public // 1= Unlisted // 2= Private
            Maker.Start()
    C#
    Code:
    Paste np = new Paste("your pastebin API key", "your pastebin username", "your pastebin password", txtCode.Text, "paste name", 2, "php", "N");
                np.Start();
    Thanks for watching this post!
    See you

    - - - Updated - - -

    Edit // Proof: https://gyazo.com/4ead8bbd0375dbd8740a36f7240b468d

  2. #2
    calfred2808's Avatar
    Join Date
    Sep 2018
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0
    it always return a error message

    "Exeption: Cannot start process because a file name has not been provided"

    how can i deal with this?
    im using vb.net
    thanks in advance.
    Last edited by calfred2808; 09-02-2018 at 08:01 AM.

  3. #3
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by calfred2808 View Post
    it always return a error message

    "Exeption: Cannot start process because a file name has not been provided"

    how can i deal with this?
    im using vb.net
    thanks in advance.
    This issue has nothing to do with OP's code. Please create a separate topic.
    Ah we-a blaze the fyah, make it bun dem!

  4. #4
    RoPMadM's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Location
    __asm
    Posts
    226
    Reputation
    12
    Thanks
    251
    My Mood
    Cynical
    Quote Originally Posted by calfred2808 View Post
    it always return a error message

    "Exeption: Cannot start process because a file name has not been provided"

    how can i deal with this?
    im using vb.net
    thanks in advance.
    There u go this is the error...
    You need to provide a file path.

  5. #5
    Lara Jean's Avatar
    Join Date
    Sep 2018
    Gender
    female
    Posts
    92
    Reputation
    98
    Thanks
    45
    Thank you very much!!

  6. #6
    Hall_Of_Fame's Avatar
    Join Date
    Sep 2017
    Gender
    male
    Posts
    29
    Reputation
    10
    Thanks
    8
    Thanks! Appreciate this!

  7. #7
    LuckerGuy's Avatar
    Join Date
    Mar 2019
    Gender
    male
    Posts
    14
    Reputation
    10
    Thanks
    12
    My Mood
    Amazed
    Thanks you!

  8. #8
    AdvenrturesOfTintin's Avatar
    Join Date
    Jul 2017
    Gender
    male
    Posts
    36
    Reputation
    10
    Thanks
    13
    is it still working? seeing now it few years ago

  9. #9
    Mrsjn's Avatar
    Join Date
    Mar 2019
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    1
    let me try it

  10. #10
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    I don't think pastebin has changed much, should be minor modifications if anything changes at all.
    Ah we-a blaze the fyah, make it bun dem!

Similar Threads

  1. Replies: 2
    Last Post: 04-09-2012, 10:32 AM
  2. Easy Class Editor for alteriw.net
    By sisadebela in forum Call of Duty Modern Warfare 2 Private Servers
    Replies: 7
    Last Post: 05-30-2010, 11:08 AM
  3. *NEW* Easy Account Maker + Classes
    By phire in forum Call of Duty Modern Warfare 2 Tutorials
    Replies: 11
    Last Post: 01-25-2010, 11:32 AM
  4. [Release] VB.Net Undetected Module Maker by PheNix
    By PheNix in forum Visual Basic Programming
    Replies: 20
    Last Post: 10-31-2009, 05:38 AM
  5. vb.net (vb2005) module maker or tutorial
    By FrancYescO in forum Visual Basic Programming
    Replies: 0
    Last Post: 04-15-2008, 01:06 AM