Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Submitted by Admin on April 28, 2014

Section 1 (PHP)

<?php 

class PastebinApi {

	var $key;
	
	public function __construct($key="public") {
		$this->key = $key;
	}
	
	public function paste($paste, $description="", $language="plain", $format="json") {
		if(function_exists('curl_init')) {
			$ch = curl_init(); 
			curl_setopt($ch, CURLOPT_URL, "http://paste.ee/api");
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
			curl_setopt($ch, CURLOPT_POST, true); 
			curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:")); 
			curl_setopt($ch, CURLOPT_HEADER, false); 
			curl_setopt($ch, CURLOPT_POSTFIELDS, array("key" => $this->key, "format" => $format, "language" => $language, "description" => $description, "paste" => $paste)); 
			
			$response = curl_exec($ch);
			
			curl_close($ch);
			
			switch($format) {
				case "json":
					return json_decode($response, true);
				case "simple":
					return $response;
			}
			return $response;
		} else {
			error_log("You need cURL to use this api!");
		}
	}
	
}
?>