|
| const | VERSION = 0.1 |
| |
| const | API_POST_URL = 'http://pastebin.com/api/api_post.php' |
| |
| const | API_FIELD_DEV_KEY = 'api_dev_key' |
| |
|
const | API_FIELD_USER_KEY = 'api_user_key' |
| |
|
const | API_FIELD_OPTION = 'api_option' |
| |
|
const | API_FIELD_PASTE_CODE = 'api_paste_code' |
| |
|
const | API_FIELD_PASTE_PRIVATE = 'api_paste_private' |
| |
|
const | API_FIELD_PASTE_NAME = 'api_paste_name' |
| |
|
const | API_FIELD_PASTE_EXPIRE_DATE = 'api_paste_expire_date' |
| |
|
const | API_FIELD_PASTE_FORMAT = 'api_paste_format' |
| |
| const | API_OPTION_CREATE = 'paste' |
| |
| const | PASTE_EXPIRE_NEVER = 'N' |
| |
|
const | PASTE_EXPIRE_10M = '10M' |
| |
|
const | PASTE_EXPIRE_1H = '1H' |
| |
|
const | PASTE_EXPIRE_1D = '1D' |
| |
|
const | PASTE_EXPIRE_1W = '1W' |
| |
|
const | PASTE_EXPIRE_2W = '2W' |
| |
|
const | PASTE_EXPIRE_1M = '1M' |
| |
| const | PASTE_PRIVACY_PUBLIC = '0' |
| |
|
const | PASTE_PRIVACY_UNLISTED = '1' |
| |
|
const | PASTE_PRIVACY_PRIVATE = '2' |
| |
|
| $apiDevKey |
| |
|
| $apiError |
| |
|
| $curlError |
| |
|
| static | $pastePrivacyTypes |
| |
| static | $pasteExpireTypes |
| |
| static | $curlOptions |
| |
cURL module is needed in order for this class to work PasteBin API wrapper class. Can be used to create new Paste.
- Author
- Marius Barbulescu
- Version
- 0.1
| PasteBin::__construct |
( |
|
$_apiKey = false | ) |
|
Instantiate a new PasteBin object.
- Parameters
-
| PasteBin::_encodeParams |
( |
array |
$_params | ) |
|
|
protected |
Prepare request params to be sent through cURL.
- Parameters
-
- Returns
- string
| PasteBin::_initRequest |
( |
| ) |
|
|
protected |
Initiates the cURL request used by other methods to send cURL requests.
- Returns
- cURL handle|false
| PasteBin::_makePostRequest |
( |
|
$_url, |
|
|
|
$_params |
|
) |
| |
|
protected |
Make a cURL request using the POST method.
- Parameters
-
| string | $_url | |
| array | $_params | |
- Returns
- string|boolean
| PasteBin::_makeRequest |
( |
|
$_url, |
|
|
|
$_params, |
|
|
|
$_type = 'get' |
|
) |
| |
|
protected |
Make a cURL request by specifying the url, params and the method.
- Parameters
-
| string | $_url | |
| array | $_params | |
| string | $_type | |
- Returns
- string|boolean
| PasteBin::_parseResponse |
( |
|
$_response | ) |
|
|
protected |
Interpret the response received from the API. Check if there is an error returned or not.
- Parameters
-
- Returns
- boolean|string
| PasteBin::_prepareExpireValue |
( |
|
$_value | ) |
|
|
protected |
Test if the expire date value is among the valid ones, else return the default value.
- Parameters
-
- Returns
- string
| PasteBin::_prepareFormatValue |
( |
|
$_value | ) |
|
|
protected |
Set proper format of the code.
- Parameters
-
- Returns
- string
| PasteBin::_preparePrivateValue |
( |
|
$_value | ) |
|
|
protected |
Test if the privacy value is among valid ones, else return the default value.
- Parameters
-
- Returns
- string
| PasteBin::_prepareRequest |
( |
|
$_url, |
|
|
|
$_type, |
|
|
|
$_params = array() |
|
) |
| |
|
protected |
Prepare the cURL request based on the http method type.
- Parameters
-
- Returns
- cURL handle
| PasteBin::createPaste |
( |
|
$_code, |
|
|
|
$_visibility = false, |
|
|
|
$_name = false, |
|
|
|
$_expire = false, |
|
|
|
$_format = false |
|
) |
| |
Create a new Paste. If everything is OK the return value will be the URL of the newly created Paste. If there was an error when the request was sent, the return value will be false. Check the error message if this is the case.
- Parameters
-
| string | $_code | |
| string | $_visibility | |
| string | $_name | |
| string | $_expire | |
| string | $_format | |
- Returns
- string|boolean The URL for the newly created Paste
Get the API key.
- Returns
- string
Return last call error, whether it was a cURL error or API error. If no error exists, false is returned.
- Returns
- string|boolean
| PasteBin::setApiKey |
( |
|
$_apiKey | ) |
|
Set the API key used to make requests.
- Parameters
-
Initial value:= array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_VERBOSE => 1,
CURLOPT_NOBODY => 0,
CURLOPT_ENCODING => 'UTF-8',
)
| PasteBin::$pasteExpireTypes |
|
static |
Initial value:= array(
self::PASTE_EXPIRE_NEVER => 'Never',
self::PASTE_EXPIRE_10M => '10 Minutes',
self::PASTE_EXPIRE_1H => '1 Hour',
self::PASTE_EXPIRE_1D => '1 Day',
self::PASTE_EXPIRE_1W => '1 Week',
self::PASTE_EXPIRE_2W => '2 Weeks',
self::PASTE_EXPIRE_1M => '1 Month',
)
| PasteBin::$pastePrivacyTypes |
|
static |
Initial value:= array(
self::PASTE_PRIVACY_PUBLIC => 'Public',
self::PASTE_PRIVACY_UNLISTED => 'Unlisted',
self::PASTE_PRIVACY_PRIVATE => 'Private',
)
| const PasteBin::API_FIELD_DEV_KEY = 'api_dev_key' |
| const PasteBin::API_OPTION_CREATE = 'paste' |
Default API option value when creating a new Paste.
| const PasteBin::API_POST_URL = 'http://pastebin.com/api/api_post.php' |
API URL for POST requests
| const PasteBin::PASTE_EXPIRE_NEVER = 'N' |
API paste expiration date values
| const PasteBin::PASTE_PRIVACY_PUBLIC = '0' |
API paste visibility types
| const PasteBin::VERSION = 0.1 |
The documentation for this class was generated from the following file:
- plugins/wikittenPlugin/plugins/PasteBin.php