· 6 years ago · Mar 27, 2020, 07:06 PM
1$api_dev_key = 'YOUR API DEVELOPER KEY'; // your api_developer_key
2$api_paste_code = 'just some random text you :)'; // your paste text
3$api_paste_private = '1'; // 0=public 1=unlisted 2=private
4$api_paste_name = 'justmyfilename.php'; // name or title of your paste
5$api_paste_expire_date = '10M';
6$api_paste_format = 'php';
7$api_user_key = ''; // if an invalid or expired api_user_key is used, an error will spawn. If no api_user_key is used, a guest paste will be created
8$api_paste_name = urlencode($api_paste_name);
9$api_paste_code = urlencode($api_paste_code);
10
11$url = 'https://pastebin.com/api/api_post.php';
12$ch = curl_init($url);
13
14curl_setopt($ch, CURLOPT_POST, true);
15curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=paste&api_user_key='.$api_user_key.'&api_paste_private='.$api_paste_private.'&api_paste_name='.$api_paste_name.'&api_paste_expire_date='.$api_paste_expire_date.'&api_paste_format='.$api_paste_format.'&api_dev_key='.$api_dev_key.'&api_paste_code='.$api_paste_code.'');
16curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
17curl_setopt($ch, CURLOPT_VERBOSE, 1);
18curl_setopt($ch, CURLOPT_NOBODY, 0);
19
20$response = curl_exec($ch);
21echo $response;
22Possible Good API Responses: (example)
23https://pastebin.com/UIFdu235s
24Possible Bad API Responses:
25Bad API request, invalid api_option
26Bad API request, invalid api_dev_key
27Bad API request, IP blocked
28Bad API request, maximum number of 25 unlisted pastes for your free account
29Bad API request, maximum number of 10 private pastes for your free account
30Bad API request, api_paste_code was empty
31Bad API request, maximum paste file size exceeded
32Bad API request, invalid api_expire_date
33Bad API request, invalid api_paste_private
34Bad API request, invalid api_paste_format
35Bad API request, invalid api_user_key
36Bad API request, invalid or expired api_user_key
37Creating A New Paste, [Required Parameters]
38Include all the following POST parameters when you request the url:
39
401. api_dev_key - which is your unique API Developers Key.
412. api_option - set as paste, this will indicate you want to create a new paste.
423. api_paste_code - this is the text that will be written inside your paste.
43
44Leaving any of these parameters out will result in an error.
45Creating A New Paste, [Optional Parameters]
46These parameters are not required when you create a new paste, but are possible to add:
47
481. api_user_key - this paramater is part of the login system, which is explained further down the page.
492. api_paste_name - this will be the name / title of your paste.
503. api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page.
514. api_paste_private - this makes a paste public, unlisted or private, public = 0, unlisted = 1, private = 2
525. api_paste_expire_date - this sets the expiration date of your paste, the values are explained futher down the page.
53Creating A New Paste, The 'api_paste_format' Paramater In Detail
54We have over 200 syntax highlighting options available, below you can find a list of all the possible values you can use in combination with api_paste_format. Always include the value on the left from the list below, the value on the right is just the full name of the language in question.
55 4cs = 4CS 6502acme = 6502 ACME Cross Asse... 6502kickass = 6502 Kick Assembler 6502tasm = 6502 TASM/64TASS abap = ABAP actionscript = ActionScript actionscript3 = ActionScript 3 ada = Ada aimms = AIMMS algol68 = ALGOL 68 apache = Apache Log applescript = AppleScript apt_sources = APT Sources arduino = Arduino arm = ARM asm = ASM (NASM) asp = ASP asymptote = Asymptote autoconf = autoconf autohotkey = Autohotkey autoit = AutoIt avisynth = Avisynth awk = Awk bascomavr = BASCOM AVR bash = Bash basic4gl = Basic4GL dos = Batch bibtex = BibTeX blitzbasic = Blitz Basic b3d = Blitz3D bmx = BlitzMax bnf = BNF boo = BOO bf = BrainFuck c = C c_winapi = C (WinAPI) c_mac = C for Macs cil = C Intermediate Language csharp = C# cpp = C++ cpp-winapi = C++ (WinAPI) cpp-qt = C++ (with Qt extensi... c_loadrunner = C: Loadrunner caddcl = CAD DCL cadlisp = CAD Lisp ceylon = Ceylon cfdg = CFDG chaiscript = ChaiScript chapel = Chapel clojure = Clojure klonec = Clone C klonecpp = Clone C++ cmake = CMake cobol = COBOL coffeescript = CoffeeScript cfm = ColdFusion css = CSS cuesheet = Cuesheet d = D dart = Dart dcl = DCL dcpu16 = DCPU-16 dcs = DCS delphi = Delphi oxygene = Delphi Prism (Oxygene) diff = Diff div = DIV dot = DOT e = E ezt = Easytrieve ecmascript = ECMAScript eiffel = Eiffel email = Email epc = EPC erlang = Erlang euphoria = Euphoria fsharp = F# falcon = Falcon filemaker = Filemaker fo = FO Language f1 = Formula One fortran = Fortran freebasic = FreeBasic freeswitch = FreeSWITCH gambas = GAMBAS gml = Game Maker gdb = GDB genero = Genero genie = Genie gettext = GetText go = Go groovy = Groovy gwbasic = GwBasic haskell = Haskell haxe = Haxe hicest = HicEst hq9plus = HQ9 Plus html4strict = HTML html5 = HTML 5 icon = Icon idl = IDL ini = INI file inno = Inno Script intercal = INTERCAL io = IO ispfpanel = ISPF Panel Definition j = J java = Java java5 = Java 5 javascript = JavaScript jcl = JCL jquery = jQuery json = JSON julia = Julia kixtart = KiXtart kotlin = Kotlin latex = Latex ldif = LDIF lb = Liberty BASIC lsl2 = Linden Scripting lisp = Lisp llvm = LLVM locobasic = Loco Basic logtalk = Logtalk lolcode = LOL Code lotusformulas = Lotus Formulas lotusscript = Lotus Script lscript = LScript lua = Lua m68k = M68000 Assembler magiksf = MagikSF make = Make mapbasic = MapBasic markdown = Markdown matlab = MatLab mirc = mIRC mmix = MIX Assembler modula2 = Modula 2 modula3 = Modula 3 68000devpac = Motorola 68000 HiSof... mpasm = MPASM mxml = MXML mysql = MySQL nagios = Nagios netrexx = NetRexx newlisp = newLISP nginx = Nginx nim = Nim text = None nsis = NullSoft Installer oberon2 = Oberon 2 objeck = Objeck Programming L... objc = Objective C ocaml = OCaml ocaml-brief = OCaml Brief octave = Octave oorexx = Open Object Rexx pf = OpenBSD PACKET FILTER glsl = OpenGL Shading oobas = Openoffice BASIC oracle11 = Oracle 11 oracle8 = Oracle 8 oz = Oz parasail = ParaSail parigp = PARI/GP pascal = Pascal pawn = Pawn pcre = PCRE per = Per perl = Perl perl6 = Perl 6 php = PHP php-brief = PHP Brief pic16 = Pic 16 pike = Pike pixelbender = Pixel Bender pli = PL/I plsql = PL/SQL postgresql = PostgreSQL postscript = PostScript povray = POV-Ray powerbuilder = PowerBuilder powershell = PowerShell proftpd = ProFTPd progress = Progress prolog = Prolog properties = Properties providex = ProvideX puppet = Puppet purebasic = PureBasic pycon = PyCon python = Python pys60 = Python for S60 q = q/kdb+ qbasic = QBasic qml = QML rsplus = R racket = Racket rails = Rails rbs = RBScript rebol = REBOL reg = REG rexx = Rexx robots = Robots rpmspec = RPM Spec ruby = Ruby gnuplot = Ruby Gnuplot rust = Rust sas = SAS scala = Scala scheme = Scheme scilab = Scilab scl = SCL sdlbasic = SdlBasic smalltalk = Smalltalk smarty = Smarty spark = SPARK sparql = SPARQL sqf = SQF sql = SQL standardml = StandardML stonescript = StoneScript sclang = SuperCollider swift = Swift systemverilog = SystemVerilog tsql = T-SQL tcl = TCL teraterm = Tera Term thinbasic = thinBasic typoscript = TypoScript unicon = Unicon uscript = UnrealScript upc = UPC urbi = Urbi vala = Vala vbnet = VB.NET vbscript = VBScript vedit = Vedit verilog = VeriLog vhdl = VHDL vim = VIM visualprolog = Visual Pro Log vb = VisualBasic visualfoxpro = VisualFoxPro whitespace = WhiteSpace whois = WHOIS winbatch = Winbatch xbasic = XBasic xml = XML xorg_conf = Xorg Config xpp = XPP yaml = YAML z80 = Z80 Assembler zxbasic = ZXBasic