本文整理汇总了PHP中OAuthStore类的典型用法代码示例。如果您正苦于以下问题:PHP OAuthStore类的具体用法?PHP OAuthStore怎么用?PHP OAuthStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OAuthStore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getResponseAPI
function getResponseAPI($userIdZyncro, $sessionid, $serviceAPI)
{
// Init the OAuthStore
$options = array('consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'server_uri' => OAUTH_HOST, 'request_token_uri' => REQUEST_TOKEN_URL, 'signature_methods' => array('HMAC-SHA1'), 'authorize_uri' => AUTHORIZE_URL, 'access_token_uri' => ACCESS_TOKEN_URL);
// Note: do not use "Session" storage in production. Prefer a database
// storage, such as MySQL.
OAuthStore::instance("Session", $options);
try {
// get a request token
$getRequestTokenParams = array();
$tokenResultParams = OAuthRequester::requestRequestToken(CONSUMER_KEY, 0, $getRequestTokenParams, 'GET');
// get an access token
$oauthToken = $tokenResultParams['token'];
$getAccessTokenParams = array('oauth_verifier' => $sessionid);
OAuthRequester::requestAccessToken(CONSUMER_KEY, $oauthToken, 0, 'POST', $getAccessTokenParams);
// make the request.
$urlRequest = OAUTH_HOST . $serviceAPI;
$request = new OAuthRequester($urlRequest, 'GET');
$result = $request->doRequest(0);
if ($result['code'] == 200) {
return $result['body'];
}
} catch (OAuthException2 $e) {
}
}
开发者ID:nachoruiz29,项目名称:javascript-api-samples,代码行数:25,代码来源:zyncro_api_functions.php
示例2: TPSession
function TPSession()
{
// define the DB store.
if (!$this->store) {
$this->store = OAuthStore::instance('MySQL', get_db_options());
}
// determine who this user is (from this site's cookie alone)
$this->user_id = get_user_id(COOKIE_NAME);
debug("[TPSession::TPSesssion], user_id = " . $this->user_id);
// If there's no user_id in the cookie, then there's no session -- not logged in.
if (!$this->user_id) {
return 0;
}
// This method look up the OAuth token in one of two ways:
// 1. the _GET parameters -- if this is the last step of the OAuth dance.
// 2. the Database -- if the user already completed the OAuth dance.
$this->oauth_token = get_oauth_token(COOKIE_NAME, $_GET, $this->store);
// debug ("OAUTH TOKEN = " . $this->oauth_token);
// Somebody wanted to log out! You should let them.
if (array_key_exists('logout', $_GET)) {
$this->log_out();
} else {
if (array_key_exists('oauth_verifier', $_GET)) {
$this->verify_access_token();
}
}
// Also update the local author record if all goes well...
if (!$this->author and $this->is_logged_in()) {
$this->update_author_record();
}
}
开发者ID:nataliepo,项目名称:Claire,代码行数:31,代码来源:tp-oauth.php
示例3: authenticate
/**
* Authenticate - Asks permission to a user to authorize the application
*
* @param string $consumerKey Access key
* @param string $secretKey Secret key
* @param integer $userId A user identificator
* @param string $callbackUri This url will be called to finish authorization
* @return void
*/
public function authenticate($consumerKey, $consumerSecret, $userId, $callbackUri)
{
// Save the server in the the OAuthStore
$store = OAuthStore::instance();
try {
// Create the server
$server = array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'server_uri' => $this->serverUrl . '/a1/', 'signature_methods' => array('HMAC-SHA1', 'PLAINTEXT'), 'request_token_uri' => $this->serverUrl . '/oauth/request_token', 'authorize_uri' => $this->serverUrl . '/oauth/authorize', 'access_token_uri' => $this->serverUrl . '/oauth/access_token');
$consumer_key = $store->updateServer($server, $userId);
} catch (Exception $e) {
//throw new BadRequestException($e->getMessage());
}
$token = OAuthRequester::requestRequestToken($consumerKey, $userId);
// Callback to our (consumer) site, will be called when the user finished the authorization at the server
$callback_uri = "{$callbackUri}?consumer_key=" . rawurlencode($consumerKey) . '&usr_id=' . intval($userId);
// Now redirect to the autorization uri and get us authorized
if (!empty($token['authorize_uri'])) {
// Redirect to the server, add a callback to our server
if (strpos($token['authorize_uri'], '?')) {
$uri = $token['authorize_uri'] . '&';
} else {
$uri = $token['authorize_uri'] . '?';
}
$uri .= 'oauth_token=' . rawurlencode($token['token']) . '&oauth_callback=' . rawurlencode($callback_uri);
} else {
// No authorization uri, assume we are authorized, exchange request token for access token
$uri = $callback_uri . '&oauth_token=' . rawurlencode($token['token']);
}
Header("Location: {$uri}");
die;
}
开发者ID:voota,项目名称:voota,代码行数:39,代码来源:voota_api.class.php
示例4: __construct
public function __construct($serviceName, $oAuthAPIRootURL, $oAuthConsumerKey, $oAuthConsumerSecret, $oAuthRequestTokenURL, $oAuthAccessTokenURL, $oAuthAuthorizeURL, $oAuthSignatureMethods, $oAuthScope, $signUpButtonURL = null, $logInButtonURL = null, $connectButtonURL = null, $activities = null)
{
parent::__construct();
$this->serviceName = $serviceName;
$this->oAuthAPIRootURL = $oAuthAPIRootURL;
$this->oAuthConsumerKey = $oAuthConsumerKey;
$this->oAuthConsumerSecret = $oAuthConsumerSecret;
$this->oAuthRequestTokenURL = $oAuthRequestTokenURL;
$this->oAuthAccessTokenURL = $oAuthAccessTokenURL;
$this->oAuthAuthorizeURL = $oAuthAuthorizeURL;
$this->oAuthSignatureMethods = $oAuthSignatureMethods;
$this->oAuthScope = $oAuthScope;
$this->signUpButtonURL = $signUpButtonURL;
$this->logInButtonURL = $logInButtonURL;
$this->connectButtonURL = $connectButtonURL;
if (!is_null($activities)) {
$this->USERBASE_ACTIVITY_OAUTH_MODULE_LOGIN = $activities[0][0];
$this->USERBASE_ACTIVITY_OAUTH_MODULE_ADDED = $activities[1][0];
$this->USERBASE_ACTIVITY_OAUTH_MODULE_REMOVED = $activities[2][0];
$this->USERBASE_ACTIVITY_OAUTH_MODULE_REGISTER = $activities[3][0];
UserConfig::$activities[$activities[0][0]] = array($activities[0][1], $activities[0][2]);
UserConfig::$activities[$activities[1][0]] = array($activities[1][1], $activities[1][2]);
UserConfig::$activities[$activities[2][0]] = array($activities[2][1], $activities[2][2]);
UserConfig::$activities[$activities[3][0]] = array($activities[3][1], $activities[3][2]);
}
$this->oAuthStore = OAuthStore::instance('MySQLi', array('conn' => UserConfig::getDB(), 'table_prefix' => UserConfig::$mysql_prefix));
}
开发者ID:russelldavis,项目名称:UserBase,代码行数:27,代码来源:OAuthModule.php
示例5: instance
/**
* Request an instance of the OAuthStore
*/
public static function instance($store = 'MySQL', $options = array())
{
if (!OAuthStore::$instance) {
// Select the store you want to use
if (strpos($store, '/') === false) {
$class = 'OAuthStore' . $store;
$file = dirname(__FILE__) . '/store/' . $class . '.php';
} else {
$file = $store;
$store = basename($file, '.php');
$class = $store;
}
if (is_file($file)) {
require_once $file;
if (class_exists($class)) {
OAuthStore::$instance = new $class($options);
} else {
throw new OAuthException2('Could not find class ' . $class . ' in file ' . $file);
}
} else {
throw new OAuthException2('No OAuthStore for ' . $store . ' (file ' . $file . ')');
}
}
return OAuthStore::$instance;
}
开发者ID:momoim,项目名称:momo-api,代码行数:28,代码来源:OAuthStore.php
示例6: authorize_action
/**
*
**/
public function authorize_action()
{
global $user, $auth;
$auth->login_if($user->id == 'nobody');
$user_id = OAuthUser::getMappedId($user->id);
// Fetch the oauth store and the oauth server.
$store = OAuthStore::instance();
$server = new OAuthServer();
try {
// Check if there is a valid request token in the current request
// Returns an array with the consumer key, consumer secret, token, token secret and token type.
$rs = $server->authorizeVerify();
if (isset($_POST['allow'])) {
// See if the user clicked the 'allow' submit button (or whatever you choose)
$authorized = array_key_exists('allow', $_POST);
// Set the request token to be authorized or not authorized
// When there was a oauth_callback then this will redirect to the consumer
$server->authorizeFinish($authorized, $user_id);
// No oauth_callback, show the user the result of the authorization
// ** your code here **
PageLayout::postMessage(Messagebox::success(_('Sie haben der Applikation Zugriff auf Ihre Daten gewährt.')));
$this->redirect('user#' . $rs['consumer_key']);
}
} catch (OAuthException $e) {
// No token to be verified in the request, show a page where the user can enter the token to be verified
// **your code here**
die('invalid');
}
PageLayout::disableHeader();
$this->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox'));
$this->rs = $rs;
}
开发者ID:noackorama,项目名称:source-talk-2012,代码行数:35,代码来源:oauth.php
示例7: run_query
public function run_query($endpoint, $params, $method = "GET")
{
if (!$this->apiKey) {
throw new Semantics3_AuthenticationError('No API key provided.');
}
if (!$this->apiSecret) {
throw new Semantics3_AuthenticationError('No API secret provided.');
}
$options = array('consumer_key' => $this->apiKey, 'consumer_secret' => $this->apiSecret);
OAuthStore::instance("2Leg", $options);
$url = $this->apiBase . $endpoint;
if ($method == "GET") {
$url = $url . "?q=" . urlencode(json_encode($params));
$params = null;
} else {
$params = json_encode($params);
}
if (!$this->catchExceptions) {
return $this->getOAuthRequester($method, $url, $params);
}
try {
return $this->getOAuthRequester($method, $url, $params);
} catch (OAuthException2 $e) {
print "\n";
$error = $e->getMessage();
print $error . "\n";
}
}
开发者ID:ahonnecke,项目名称:semantics3-php,代码行数:28,代码来源:ApiConnector.php
示例8: __construct
/**
* Creates a new instance of OsmOAuth.
*
* @param string $key The consumer key.
* @param string $secret The consumer secret.
* @param boolean $unitTest Determines wheter this call is made from a unit test or not.
*/
public function __construct($key, $secret, $unitTest = false)
{
$this->key = $key;
$this->secret = $secret;
if (!$unitTest) {
\OAuthStore::instance("Session", $this->getOauthOptions());
}
}
开发者ID:CloCkWeRX,项目名称:kort,代码行数:15,代码来源:OsmOAuth.php
示例9: grant_access_token_to_consumer
function grant_access_token_to_consumer($consumer_key, $user_id)
{
$store = OAuthStore::instance();
$token_info = $store->addConsumerRequestToken($consumer_key);
$store->authorizeConsumerRequestToken($token_info['token'], $user_id);
$token_and_secret = $store->exchangeConsumerRequestForAccessToken($token_info['token']);
return $token_and_secret;
}
开发者ID:niczap,项目名称:socialigniter,代码行数:8,代码来源:Social_auth.php
示例10: setinstance
public function setinstance()
{
$registry = Zend_Registry::getInstance();
$config = $registry->get("config");
$db = $config['resources']['db']['params'];
require_once EXTERNAL_LIBRARY_PATH . '/oauth-php/library/OAuthStore.php';
OAuthStore::instance("MySQL", array("server" => $db['host'], "database" => $db['dbname'], "username" => $db['username'], "password" => $db['password']));
}
开发者ID:henvic,项目名称:MediaLab,代码行数:8,代码来源:LoadOauthstore.php
示例11: listapiserversAction
public function listapiserversAction()
{
$service = new Ml_Model_Service();
$userId = $service->getInput("User ID");
$this->_helper->loadOauthstore->setinstance();
$store = OAuthStore::instance();
$servers = $store->listServers(null, $userId);
print_r($servers);
}
开发者ID:henvic,项目名称:MediaLab,代码行数:9,代码来源:TestController.php
示例12: oauth_init
public function oauth_init()
{
Yii::import('application.modules.api.vendors.*');
require_once "oauth-php/library/OAuthServer.php";
require_once "oauth-php/library/OAuthStore.php";
#require_once("oauth-php/init.php");
$options = array('dsn' => $this->connectionString, 'username' => $this->username, 'password' => $this->password);
OAuthStore::instance('PDO', $options);
}
开发者ID:vangogogo,项目名称:justsns,代码行数:9,代码来源:ApiModule.php
示例13: __construct
function __construct()
{
require_once APPPATH . 'libraries/oauth/OAuthStore.php';
require_once APPPATH . 'libraries/oauth/OAuthServer.php';
require_once APPPATH . 'libraries/oauth/OAuthRequester.php';
$this->_CI =& get_instance();
$this->_CI->config->load('oauth');
$db_options = array('server' => $this->_CI->config->item('db_server'), 'username' => $this->_CI->config->item('db_username'), 'password' => $this->_CI->config->item('db_password'), 'database' => $this->_CI->config->item('db_name'));
$this->oauth_store = OAuthStore::instance('MySQL', $db_options);
$this->oauth_server = new OAuthServer();
}
开发者ID:nnrv1ncentsh1,项目名称:MADA,代码行数:11,代码来源:oauth_server.php
示例14: __construct
/**
* Constructor. Creates authenticated access to Factual.
* @param string key your oauth key.
* @param string secret your oauth secret.
*/
public function __construct($key, $secret)
{
//load configuration
$this->loadConfig();
$this->factHome = $this->config['factual']['endpoint'];
//assign endpoint
//create authentication object
$options = array('consumer_key' => $key, 'consumer_secret' => $secret);
$this->signer = OAuthStore::instance("2Leg", $options);
//register autoloader
spl_autoload_register(array(get_class(), 'factualAutoload'));
}
开发者ID:neostoic,项目名称:whynotv3,代码行数:17,代码来源:Factual.php
示例15: SignUrl
/**
* Given a URL return an OAuth signed URL. This will handle creating a timestamp and nonce
*
* @param string $url the unsigned url
* @param string $method request method GET, POST, PUT, DELETE
* @param string $key oauth key
* @param string $secret oauth secret
* @param array $params querystring or post parameters
* @param string $body the body contents of the request
* @param string $signature_method method used for signature (default = 'HMAC_SHA1')
*/
public static function SignUrl($url, $method, $key, $secret, $params = null, $body = null, $signature_method = 'HMAC_SHA1')
{
$options = array('consumer_key' => $key, 'consumer_secret' => $secret);
$params = $params ? $params : array();
OAuthStore::instance("2Leg", $options);
// Obtain a request object for the request we want to make
$request = new OAuthRequester($url, $method, $params, $body);
$sig = $request->sign($key, null, '');
$data = $request->signatureBaseString();
$url = substr(urldecode($data . '&oauth_signature=' . $request->calculateDataSignature($data, $secret, '', $signature_method)), strlen($method) + 1);
$url = VerySimpleStringUtil::ReplaceFirst('&', '?', $url);
return $url;
}
开发者ID:hpazevedo,项目名称:Teste-BDR,代码行数:24,代码来源:OAuthUtil.php
示例16: douban_oauth
function douban_oauth()
{
include 'lib/oauth/OAuthStore.php';
include 'lib/oauth/OAuthRequester.php';
define('DOUBAN_KEY', '0df3d98366dc5c4829db8c8a349514d8');
define('DOUBAN_SECRET', 'e6265a67126d5895');
define('DOUBAN_REQUEST_TOKEN_URL', 'http://www.douban.com/service/auth/request_token');
define('DOUBAN_AUTHORIZE_URL', 'http://www.douban.com/service/auth/authorize');
define('DOUBAN_ACCESS_TOKEN_URL', 'http://www.douban.com/service/auth/access_token');
define('OAUTH_TMP_DIR', function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : realpath($_ENV['TMP']));
$options = array('consumer_key' => DOUBAN_KEY, 'consumer_secret' => DOUBAN_SECRET, 'server_uri' => 'http://api.douban.com/', 'request_token_uri' => DOUBAN_REQUEST_TOKEN_URL, 'authorize_uri' => DOUBAN_AUTHORIZE_URL, 'access_token_uri' => DOUBAN_ACCESS_TOKEN_URL);
OAuthStore::instance('Session', $options);
}
开发者ID:reusee,项目名称:defphp,代码行数:13,代码来源:douban_oauth.php
示例17: getOAuthAccessor
/**
* Retrieve an OAuthAccessor that is ready to sign OAuthMessages.
*
* @param tokenKey information about the gadget retrieving the accessor.
*
* @return an OAuthAccessorInfo containing an OAuthAccessor (whic can be
* passed to an OAuthMessage.sign method), as well as httpMethod and
* signatureType fields.
*/
public function getOAuthAccessor(TokenKey $tokenKey, $ignoreCache)
{
$gadgetUri = $tokenKey->getGadgetUri();
if (empty($gadgetUri)) {
throw new OAuthStoreException("found empty gadget URI in TokenKey");
}
$getUserId = $tokenKey->getUserId();
if (empty($getUserId)) {
throw new OAuthStoreException("found empty userId in TokenKey");
}
$gadgetSpec = $this->specFactory->getGadgetSpecUri($gadgetUri, $ignoreCache);
$provInfo = $this->getProviderInfo($gadgetSpec, $tokenKey->getServiceName());
return $this->store->getOAuthAccessorTokenKey($tokenKey, $provInfo);
}
开发者ID:vuxuandung,项目名称:Partuza-bundle,代码行数:23,代码来源:GadgetOAuthTokenStore.php
示例18: storeInstance
public static function storeInstance()
{
$dbConf = Propel::getConfiguration();
$dsn = $dbConf['datasources']['propel']['connection']['dsn'];
if (preg_match("/dbname=(.*);host=(.*)\$/", $dsn, $matches)) {
$db = $matches[1];
$host = $matches[2];
}
$store = OAuthStore::instance('MySQL', array('server' => $host, 'username' => $dbConf['datasources']['propel']['connection']['user'], 'password' => $dbConf['datasources']['propel']['connection']['password'], 'database' => $db));
if (!$store) {
sfContext::getInstance()->getLogger()->err("Cannot connect to database.");
throw new OAuthException("Cannot connect to database.");
}
return $store;
}
开发者ID:voota,项目名称:voota,代码行数:15,代码来源:oauthSecurityManager.class.php
示例19: __construct
/**
* Construct the request to be verified
*
* @param string request
* @param string method
* @param array params The request parameters
*/
function __construct($uri = null, $method = null, $params = null)
{
if ($params) {
$encodedParams = array();
foreach ($params as $key => $value) {
if (preg_match("/^oauth_/", $key)) {
continue;
}
$encodedParams[rawurlencode($key)] = rawurlencode($value);
}
$this->param = array_merge($this->param, $encodedParams);
}
$this->store = OAuthStore::instance();
parent::__construct($uri, $method);
LingotekOAuthRequestLogger::start($this);
}
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:23,代码来源:LingotekOAuthRequestVerifier.php
示例20: run_query
public function run_query($endpoint, $params, $method="GET")
{
if (!$this->apiKey)
throw new Semantics3_AuthenticationError('No API key provided.');
if (!$this->apiSecret)
throw new Semantics3_AuthenticationError('No API secret provided.');
$options = array( 'consumer_key' => $this->apiKey, 'consumer_secret' => $this->apiSecret );
OAuthStore::instance("2Leg", $options );
$url = $this->apiBase.$endpoint;
if ($method == "GET") {
$url = $url."?q=".urlencode(json_encode($params));
$params = null;
}
else {
$params = json_encode($params);
}
try
{
switch ($method) {
case "GET":
$request = new OAuthRequester($url, $method, $params);
break;
case "POST":
$request = new OAuthRequester($url, $method, '', $params);
break;
case "DELETE":
$request = new OAuthRequester($url, $method);
break;
default:
$request = new OAuthRequester($url, $method);
}
$result = $request->doRequest();
return $result['body'];
}
catch(OAuthException2 $e)
{
print "\n";
$error = $e->getMessage();
print $error."\n";
}
}
开发者ID:kuroware,项目名称:htn-scale,代码行数:46,代码来源:ApiConnector.php
注:本文中的OAuthStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论