当前位置: 首页>>代码示例>>PHP>>正文


PHP Configuration::getDataStore方法代码示例

本文整理汇总了PHP中Configuration::getDataStore方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::getDataStore方法的具体用法?PHP Configuration::getDataStore怎么用?PHP Configuration::getDataStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Configuration的用法示例。


在下文中一共展示了Configuration::getDataStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AutoLoader

if (!isset($_GET['oauth_token'])) {
    echo "No token supplied.";
    exit;
}
require_once __DIR__ . '/../../lib/AutoLoader.php';
new AutoLoader();
try {
    $RequestToken = OAuthRequestTokenModel::loadFromToken($_GET['oauth_token'], Configuration::getDataStore());
} catch (DataStoreReadException $Exception) {
    echo $Exception->getMessage();
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['allow'])) {
    // User has no model, it just here by example, hence the open MySQL query
    // This is not a good way to actually store user data (plaintext password wtf)
    $DB = Configuration::getDataStore();
    $sql = "SELECT `user_id`, `user_name`, `user_password` FROM `user` WHERE `user_name` = '" . $DB->real_escape_string($_POST['user_name']) . "'";
    $result = $DB->query($sql);
    $row = $result->fetch_assoc();
    $result->close();
    if ($row['user_password'] != $_POST['user_password']) {
        echo "You hacker, be gone!";
        exit;
    }
    $verificationCode = OAuthProviderWrapper::generateToken();
    $RequestToken->setTokenVerificationCode($verificationCode);
    $RequestToken->setTokenUserId($row['user_id']);
    try {
        $RequestToken->save();
    } catch (DataStoreUpdateException $Exception) {
        echo $Exception->getMessage();
开发者ID:navanjr,项目名称:OAuth-consumer,代码行数:31,代码来源:authorize.php

示例2: AutoLoader

<?php

/**
 * @author      Freek Lijten <freek@procurios.nl>
 */
require_once __DIR__ . '/../../lib/AutoLoader.php';
new AutoLoader();
$Provider = new OAuthProviderWrapper(OAuthProviderWrapper::TOKEN_VERIFY);
$response = $Provider->checkOAuthRequest();
if ($response !== true) {
    echo $response;
    exit;
}
try {
    $userId = $Provider->getUserId();
} catch (ProviderException $Exception) {
    $Exception->getMessage();
}
$sql = "SELECT * FROM `user_messages` WHERE `user_id` = '" . $userId . "'";
$result = Configuration::getDataStore()->query($sql);
$returnValue = "<messages>";
while ($row = $result->fetch_assoc()) {
    $returnValue .= "<message>" . $row['message_text'] . "</message>";
}
$returnValue .= "</messages>";
//Token is valid, lets output something
echo $returnValue;
开发者ID:navanjr,项目名称:OAuth-consumer,代码行数:27,代码来源:api.php

示例3: AutoLoader

<?php

/**
 * @Author	Freek Lijten
 */
require_once __DIR__ . '/../../lib/AutoLoader.php';
new AutoLoader();
//create consumer model
$Consumer = new OAuthConsumerModel(Configuration::getDataStore());
$Consumer->setConsumerCreateDate(time());
$Consumer->setConsumerKey(OAuthProviderWrapper::generateToken());
$Consumer->setConsumerSecret(OAuthProviderWrapper::generateToken());
try {
    $Consumer->save();
} catch (DataStoreCreateException $Exception) {
    echo $Exception->getMessage();
    exit;
}
echo "Consumer key: " . $Consumer->getConsumerKey() . "<br />Consumer secret: " . $Consumer->getConsumerSecret();
开发者ID:navanjr,项目名称:OAuth-consumer,代码行数:19,代码来源:create_consumer.php

示例4: checkAccessToken

 /**
  * Checks if there is token information for the provided access token and sets the secret if it can be found.
  *
  * @static
  * @param 	$Provider
  * @return 	int
  */
 public static function checkAccessToken($Provider)
 {
     // Ideally this function should rethrow exceptions, but the internals of PECL's OAuth class
     // Expect one of the OAUTH constants to be returned. When left out an exception is thrown, negating
     // out exception thrown here.
     try {
         $DataStore = Configuration::getDataStore();
     } catch (DataStoreConnectException $Exception) {
         return OAUTH_TOKEN_REJECTED;
     }
     //Try to load the access token
     try {
         $AccessToken = OAuthAccessTokenModel::loadFromToken($Provider->token, $DataStore);
     } catch (DataStoreReadException $Exception) {
         return OAUTH_TOKEN_REJECTED;
     }
     //The consumer must be the same as the one this request token was originally issued for
     if ($AccessToken->getAccessTokenConsumerKey() != $Provider->consumer_key) {
         return OAUTH_TOKEN_REJECTED;
     }
     $Provider->token_secret = $AccessToken->getAccessTokenSecret();
     return OAUTH_OK;
 }
开发者ID:navanjr,项目名称:OAuth-consumer,代码行数:30,代码来源:OAuthProviderWrapper.php


注:本文中的Configuration::getDataStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。