Skip to content

Instantly share code, notes, and snippets.

@zircote
Created February 16, 2012 13:55
Show Gist options
  • Select an option

  • Save zircote/1844975 to your computer and use it in GitHub Desktop.

Select an option

Save zircote/1844975 to your computer and use it in GitHub Desktop.
Completion template for pecl oauth extension
<?php
/**
* @var string
* OAuth RSA-SHA1 signature method.
*/
define('OAUTH_SIG_METHOD_RSASHA1');
/**
* OAuth HMAC-SHA1 signature method.
*
* @var string
*/
define('OAUTH_SIG_METHOD_HMACSHA1');
/**
* OAuth HMAC-SHA256 signature method.
*
* @var string
*/
define('OAUTH_SIG_METHOD_HMACSHA256');
/**
* This constant represents putting OAuth parameters in the Authorization
* header.
*
* @var string
*/
define('OAUTH_AUTH_TYPE_AUTHORIZATION');
/**
* This constant indicates a NoAuth OAuth request.
*
* @var string
*/
define('OAUTH_AUTH_TYPE_NONE');
/**
* This constant represents putting OAuth parameters in the request URI.
*
* @var string
*/
define('OAUTH_AUTH_TYPE_URI');
/**
* This constant represents putting OAuth parameters as part of the HTTP POST
* body.
*
* @var string
*/
define('OAUTH_AUTH_TYPE_FORM');
/**
* Use the GET method for the OAuth request.
*
* @var string
*/
define('OAUTH_HTTP_METHOD_GET');
/**
* Use the POST method for the OAuth request.
*
* @var string
*/
define('OAUTH_HTTP_METHOD_POST');
/**
* Use the PUT method for the OAuth request.
*
* @var string
*/
define('OAUTH_HTTP_METHOD_PUT');
/**
* Use the HEAD method for the OAuth request.
*
* @var strubg
*/
define('OAUTH_HTTP_METHOD_HEAD');
/**
* Use the DELETE method for the OAuth request
*
* @var string
*/
define('OAUTH_HTTP_METHOD_DELETE');
/**
* Used by setRequestEngine() to set the engine to PHP streams, as
* opposed to define('OAUTH_REQENGINE_CURL for Curl.
*
* @var string
*/
define('OAUTH_REQENGINE_STREAMS');
/**
* Used by setRequestEngine() to set the engine to Curl, as opposed to
* define('OAUTH_REQENGINE_STREAMS for PHP streams.
*
* @var string
*/
define('OAUTH_REQENGINE_CURL');
/**
* Life is good.
*
* @var integer
*/
define('OAUTH_OK');
/**
* The define('OAUTH_nonce value was used in a previous request, therefore it
* cannot be used now.
*
* @var integer
*/
define('OAUTH_BAD_NONCE');
/**
* The define('OAUTH_timestamp value was not accepted by the service provider.
*
* In this case, the response should also contain the
* OAUTH_acceptable_timestamps
* parameter.
*
* @var integer
*/
define('OAUTH_BAD_TIMESTAMP');
/**
* The OAUTH_consumer_key is temporarily unacceptable to the service provider.
*
* For example, the service provider may be throttling the consumer.
*
* @var integer
*/
define('OAUTH_CONSUMER_KEY_UNKNOWN');
/**
* The consumer key was refused.
*
* @var integer
*/
define('OAUTH_CONSUMER_KEY_REFUSED');
/**
* The define('OAUTH_signature is invalid, as it does not match the signature
* computed by the service provider.
*
* @var integer
*/
define('OAUTH_INVALID_SIGNATURE');
/**
* The define('OAUTH_token has been consumed.
* It can no longer be used because
* it has already been used in the previous request(s).
*
* @var integer
*/
define('OAUTH_TOKEN_USED');
/**
* The define('OAUTH_token has expired.
*
* @var integer
*/
define('OAUTH_TOKEN_EXPIRED');
/**
* The define('OAUTH_token has been revoked, and will never be accepted.
*
* @var integer
*/
define('OAUTH_TOKEN_REVOKED');
/**
* The define('OAUTH_token was not accepted by the service provider.
* The reason
* is not known, but it might be because the token was never issued, already
* consumed, expired, and/or forgotten by the service provider.
*
* @var integer
*/
define('OAUTH_TOKEN_REJECTED');
/**
* The define('OAUTH_verifier is incorrect.
*
* @var integer
*/
define('OAUTH_VERIFIER_INVALID');
/**
* A required parameter was not received.
* In this case, the response should also
* contain the define('OAUTH_parameters_absent parameter.
*
* @var integer
*/
define('OAUTH_PARAMETER_ABSENT');
/**
* The define('OAUTH_signature_method was not accepted by service provider.
*
* @var integer
*/
define('OAUTH_SIGNATURE_METHOD_REJECTED');
/**
* Generate a Signature Base String
*
* @param $http_method string
* @param $uri string
* @param $request_parameters array
* @return string
*/
function oauth_get_sbs ($http_method, $uri, $request_parameters = array())
{}
/**
* Encode a URI to RFC 3986
*
* @param $uri string
* @return string
*/
function oauth_urlencode ($uri)
{}
class OAuth
{
public $debug;
public $sslChecks;
public $debugInfo;
/**
* Create a new OAuth object
* @param $consumer_key string
* @param $consumer_secret string
* @param $signature_method string
* @param $auth_type int
*/
public function __construct ($consumer_key, $consumer_secret,
$signature_method = OAUTH_SIG_METHOD_HMACSHA1, $auth_type = 0)
{}
/**
* The destructor
* @return void
*/
public function __destruct ()
{}
/**
* Turn off verbose debugging
* @return bool
*/
public function disableDebug ()
{}
/**
* Turn off redirects
* @return bool
*/
public function disableRedirects ()
{}
/**
* Turn off SSL checks
* @return bool
*/
public function disableSSLChecks ()
{}
/**
* Turn on verbose debugging
* @return bool
*/
public function enableDebug ()
{}
/**
* Turn on redirects
* @return bool
*/
public function enableRedirects ()
{}
/**
* Turn on SSL checks
* @return bool
*/
public function enableSSLChecks ()
{}
/**
* Fetch an OAuth protected resource
* @param $protected_resource_url string
* @param $extra_parameters array
* @param $http_method string
* @param $http_headers array
* @return mixed
*/
public function fetch ($protected_resource_url, $extra_parameters,
$http_method, $http_headers)
{}
/**
* Generate a signature
* @return string
*/
public function generateSignature ($http_method, $url, $extra_parameters)
{}
/**
* Fetch an access token
* @param $access_token_url string
* @param $auth_session_handle string
* @param $verifier_token string
* @return array
*/
public function getAccessToken ($access_token_url, $auth_session_handle,
$verifier_token)
{}
/**
* Gets CA information
* @return array
*/
public function getCAPath ()
{}
/**
* Get the last response
* @return string
*/
public function getLastResponse ()
{}
/**
* Get headers for last response
* @return string
*/
public function getLastResponseHeaders ()
{}
/**
* Get HTTP information about the last response
* @return array
*/
public function getLastResponseInfo ()
{}
/**
* Generate OAuth header string signature
* @param $http_method string
* @param $url string
* @param $extra_parameters mixed
* @return string
*/
public function getRequestHeader ($http_method, $url, $extra_parameters)
{}
/**
* Fetch a request token
* @param $request_token_url string
* @param $callback_url string
* @return array
*/
public function getRequestToken ($request_token_url, $callback_url)
{}
/**
* Set authorization type
* @return mixed
*/
public function setAuthType ($auth_type)
{}
/**
* Set CA path and info
* @param $ca_path string
* @param $ca_info string
* @return mixed
*/
public function setCAPath ($ca_path, $ca_info)
{}
/**
* Set the nonce for subsequent requests
* @param $nonce string
* @return mixed
*/
public function setNonce ($nonce)
{}
/**
* The setRequestEngine purpose
* @param $reqengine int
* @return void
*/
public function setRequestEngine ($reqengine)
{}
/**
* Set the RSA certificate
* @param $cert string
* @return mixed
*/
public function setRSACertificate ($cert)
{}
/**
* Tweak specific SSL checks for requests.
* @param $sslcheck int
* @return bool
*/
public function setSSLChecks ($sslcheck)
{}
/**
* Set the timestamp
* @param $timestamp string
* @return mixed
*/
public function setTimestamp ($timestamp)
{}
/**
* Sets the token and secret
* @param $token string
* @param $token_secret string
* @return bool
*/
public function setToken ($token, $token_secret)
{}
/**
* Set the OAuth version
* @param $version string
* @return bool
*/
public function setVersion ($version)
{}
}
class OAuthProvider
{
/**
* Add required parameters
* @param $req_params string
* @return bool
*/
final public function addRequiredParameter ($req_params)
{}
/**
* Calls the consumerNonceHandler callback
* @return void
*/
public function callconsumerHandler ()
{}
/**
* Calls the timestampNonceHandler callback
* @return void
*/
public function callTimestampNonceHandler ()
{}
/**
* Calls the tokenNonceHandler callback
* @return void
*/
public function calltokenHandler ()
{}
/**
* Check an oauth request
* @param $uri string
* @param $method string
*/
public function checkOAuthRequest ($uri, $method)
{}
/**
* Constructs a new OAuthProvider object
* @param $params_array array
*/
public function __construct ($params_array)
{}
/**
* Set the consumerHandler handler callback
* @param $callback_function callback
*/
public function consumerHandler ($callback_function)
{}
/**
* Generate a random token
* @param $size int
* @param $strong bool
* @return string
*/
final public static function generateToken ($size, $strong = false)
{}
/**
* is2LeggedEndpoint
* @param $params_array mixed
*/
public function is2LeggedEndpoint ($params_array)
{}
/**
* Sets isRequestTokenEndpoint
* @param $will_issue_request_token bool
*/
public function isRequestTokenEndpoint ($will_issue_request_token)
{}
/**
* Remove a required parameter
* @param $req_params string
* @return bool
*/
final public function removeRequiredParameter ($req_params)
{}
/**
* Report a problem
* @param $oauthexception string
* @param $send_headers bool
* @return string
*/
final public static function reportProblem ($oauthexception,
bool $send_headers = true)
{}
/**
* Set a parameter
* @param $param_key string
* @param $param_val mixed
* @return bool
*/
final public function setParam ($param_key, $param_val)
{}
/**
* Set request token path
* @param $path string
* @return bool
*/
final public function setRequestTokenPath ($path)
{}
/**
* Set the timestampNonceHandler handler callback
* @param $callback_function callback
*/
public function timestampNonceHandler ($callback_function)
{}
/**
* Set the tokenHandler handler callback
* @param $callback_function callback
*/
public function tokenHandler ($callback_function)
{}
}
/**
* This exception is thrown when exceptional errors occur while using the OAuth
* extension and contains useful debugging information.
*
*/
class OAuthException extends Exception {
/**
* The response of the exception which occurred, if any
* @var string
*/
public $lastResponse ;
/**
*
* @var mixed
*/
public $debugInfo ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment