本文整理汇总了PHP中Token::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Token::get方法的具体用法?PHP Token::get怎么用?PHP Token::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public static function update($userid)
{
global $HTTP_CONFIG;
$username = Token::get(self::name, $userid);
$request = new HTTP_Request2('https://hacker-news.firebaseio.com/v0/user/' . $username . '.json');
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$karma = json_decode($response)->karma;
Score::update(self::name, $userid, $karma);
}
示例2: update
public static function update($userid)
{
global $HTTP_CONFIG;
$username = Token::get(self::name, $userid);
$request = new HTTP_Request2('http://open.dapper.net/transform.php?dappName=CodeChefProblemsSolved&transformer=JSON&v_username=' . $username);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$score = json_decode($response)->fields->solved[32]->value;
Score::update(self::name, $userid, $score);
}
示例3: update
public static function update($userid)
{
global $HTTP_CONFIG;
$lastFMUsername = Token::get(self::name, $userid);
$request = new HTTP_Request2('http://ws.audioscrobbler.com/2.0/?method=user.getinfo&user=' . $lastFMUsername . '&api_key=' . LASTFM_APP_ID . '&format=json');
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$playcount = trim(json_decode($response)->user->playcount);
Score::update(self::name, $userid, $playcount);
//Update in database
}
示例4: update
public static function update($userid)
{
global $HTTP_CONFIG;
$id = Token::get(self::name, $userid);
$request = new HTTP_Request2('https://api.stackexchange.com/2.1/users/' . $id . '?site=askubuntu&key=' . STACKEXCHANGE_KEY);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$reputation = json_decode($response)->items[0]->reputation;
Score::update(self::name, $userid, $reputation);
//Update in database
}
示例5: update
public static function update($userid)
{
global $HTTP_CONFIG;
$access_token = Token::get(self::name, $userid);
$request = new HTTP_Request2("https://graph.facebook.com/me/subscribers?access_token={$access_token}");
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$subscribersCount = json_decode($response)->summary->total_count;
Score::update(self::name, $userid, $subscribersCount);
//Update in database
}
示例6: update
public static function update($userid)
{
global $HTTP_CONFIG;
$twitterScreenName = Token::get(self::name, $userid);
$request = new HTTP_Request2('https://api.twitter.com/1/users/show.json?screen_name=' . $twitterScreenName);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$followers_count = json_decode($response)->followers_count;
Score::update(self::name, $userid, $followers_count);
//Update in database
}
示例7: update
public static function update($userid)
{
global $HTTP_CONFIG;
$username = Token::get(self::name, $userid);
//More information at http://geekraj.com/wordpress/?p=278
//see http://geekraj.com/euler/euler.js
$request = new HTTP_Request2('http://www.geekraj.com/euler/getscore.php?id=' . $username);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$score = json_decode(str_replace("'", '"', substr($response, 12, -2)))->score;
$score = substr($score, 7);
Score::update(self::name, $userid, $score);
}
示例8: update
public static function update($userid)
{
global $HTTP_CONFIG;
$id = Token::get(self::name, $userid);
$request = new HTTP_Request2('http://api.klout.com/v2/identity.json/twitter?screenName=' . $id . '&key=' . KLOUT_APP_KEY);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$id = json_decode($response)->id;
$request = new HTTP_Request2('http://api.klout.com/v2/user.json/' . $id . '/score?key=' . KLOUT_APP_KEY);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$score = (int) json_decode($response)->score;
Score::update(self::name, $userid, $score);
//Update in database
}
示例9: update
public static function update($userid)
{
global $HTTP_CONFIG;
$username = Token::get(self::name, $userid);
$request = new HTTP_Request2('http://open.dapper.net/transform.php?dappName=ScoreFromSpoj&transformer=JSON&v_username=' . $username);
$request->setConfig($HTTP_CONFIG);
$response = $request->send()->getBody();
$score = json_decode($response)->fields->score[0]->value;
/*
* The score is formatted as
* (n points)
*/
$spacePosition = strpos($score, ' ');
$score = substr($score, 1, $spacePosition - 1);
Score::update(self::name, $userid, $score);
}
示例10: callback
public static function callback()
{
global $HTTP_CONFIG;
//exchange the code you get for a access_token
$code = $_GET['code'];
$request = new HTTP_Request2(self::ACCESS_TOKEN_URL);
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig($HTTP_CONFIG);
$request->addPostParameter(['client_id' => GITHUB_APP_ID, 'client_secret' => GITHUB_APP_SECRET, 'code' => $code]);
$request->setHeader('Accept', 'application/json');
$response = $request->send();
$response = json_decode($response->getBody());
$access_token = $response->access_token;
//Use this access token to get user details
$request = new HTTP_Request2(self::USER_URL . '?access_token=' . $access_token, HTTP_Request2::METHOD_GET, $HTTP_CONFIG);
$response = $request->send()->getBody();
$userid = json_decode($response)->login;
//get the userid
//If such a user already exists in the database
//Just log him in and don't touch the access_token
$already_present_token = Token::get('github', $userid);
if ($already_present_token) {
$_SESSION['userid'] = $userid;
redirect_to('/');
}
if (defined('GITHUB_ORGANIZATION')) {
// perform the organization check
$request = new HTTP_Request2(json_decode($response)->organizations_url . '?access_token=' . $access_token, HTTP_Request2::METHOD_GET, $HTTP_CONFIG);
$response = $request->send()->getBody();
//List of organizations
$organizations_list = array_map(function ($repo) {
return $repo->login;
}, json_decode($response));
if (in_array(GITHUB_ORGANIZATION, $organizations_list)) {
$_SESSION['userid'] = $userid;
Token::add('github', $userid, $access_token);
} else {
throw new Exception('You are not in the listed members.');
}
} else {
$_SESSION['userid'] = $userid;
Token::add('github', $userid, $access_token);
}
redirect_to('/');
}
示例11: auth
public function auth()
{
$client_id = $this->input->get('clent_id');
$application = new Application();
$application->client_id = $client_id;
$application->get();
if (!$application->exists()) {
$data['title'] = 'Auth Page';
$data['content'] = 'oauth/noapplication';
$this->load->view('master', $data);
} elseif (!$this->user_id) {
$redirect = 'users/login?redirect_url=oauth/auth?client_id=' . $application->id;
redirect($redirect);
} elseif ($this->input->post()) {
$allow = $this->input->post('allow');
if ($allow) {
$user = new User($this->user_id);
$existing_token = new Token();
$existing_token->where('user_id', $user->id);
$existing_token->where('application_id', $application->id);
$existing_token->get();
if ($existing_token->exists()) {
$existing_token->delete();
}
$token = $this->generate_token();
$token->save(array($application, $user));
die;
echo 'here';
}
} else {
$this->load->helper('form');
$data['application'] = array('id' => $application->id, 'name' => $application->name, 'client_id' => $application->client_id, 'client_secret' => $application->client_secret, 'redirect_url' => $application->redirect_url);
$data['title'] = 'Auth Page';
$data['content'] = 'oauth/authorize';
$this->load->view('master', $data);
}
}
示例12: cleanExpire
private function cleanExpire()
{
$arch = new Archiviste();
$token = new Token();
$tokens = $arch->restituer($token);
$toDay = time();
foreach ($tokens as $tokenTemp) {
$token = new Token();
$token->setAttributs($tokenTemp->getAttributs());
$expire = $token->get("expire");
if ($expire < $toDay) {
$arch->supprimer($token);
}
}
}
示例13: dispatch
* Home page shows all scores
* for all users
*/
dispatch('/', 'Score::view_all');
dispatch('/debug', function () {
return json($_SESSION);
});
/* Authentication Related Stuff */
dispatch('/login/:service', function () {
$serviceClassName = ucfirst(params('service'));
//since github is our main authentication method
//we allow that to run unauthenticated
if (!@$_SESSION['userid'] && $serviceClassName != 'Github') {
throw new Exception('You need to be logged in');
}
set('username', Token::get(params('service'), $_SESSION['userid']));
return $obj = $serviceClassName::login();
});
dispatch('/login/:service/callback', function () {
$serviceClassName = ucfirst(params('service'));
if (!@$_SESSION['userid'] && $serviceClassName != 'Github') {
throw new Exception('You need to be logged in');
}
return $serviceClassName::callback();
});
dispatch('/logout', function () {
unset($_SESSION['userid']);
redirect_to('/');
});
/*
* Update score for a particular