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!");
		}
	}
	
}
?>