public function onSloginAuth() { $oauthapp = new YahooOAuthApplication($this->key, $this->secret, $this->app_id, $this->callback); # Fetch request token $request_token = $oauthapp->getRequestToken($this->callback); $session = JFactory::getSession(); $session->set('request_token', serialize($request_token)); # Redirect user to authorization url $redirect_url = $oauthapp->getAuthorizationUrl($request_token); return $redirect_url; }
/** * connect */ public function connect() { $oauthapp = new YahooOAuthApplication($this->key, $this->secret, $this->appId, $this->domain); # Fetch request token $request_token = $oauthapp->getRequestToken($this->redirect_url); $_SESSION['request_token'] = get_object_vars($request_token); # Redirect user to authorization url $redirect_url = $oauthapp->getAuthorizationUrl($request_token); header('Location: ' . $redirect_url); exit; }
public function onSloginAuth() { if ($this->params->get('allow_remote_check', 1)) { $remotelUrl = JURI::getInstance($_SERVER['HTTP_REFERER'])->toString(array('host')); $localUrl = JURI::getInstance()->toString(array('host')); if ($remotelUrl != $localUrl) { die('Remote authorization not allowed'); } } $oauthapp = new YahooOAuthApplication($this->key, $this->secret, $this->app_id, $this->callback); # Fetch request token $request_token = $oauthapp->getRequestToken($this->callback); $session = JFactory::getSession(); $session->set('request_token', serialize($request_token)); # Redirect user to authorization url $redirect_url = $oauthapp->getAuthorizationUrl($request_token); return $redirect_url; }
/* * TODO: Deal with token refreshing */ require_once dirname(__FILE__) . '/../../lib/Yahoo/YahooMeme.class.php'; $action = null; if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } // this URL will be called after user login. Don't forget to exchange the token!!! $callback = 'http://localhost/yos/examples/meme/oAuthExample.php?action=authorized'; $app = new YahooOAuthApplication(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID, OAUTH_DOMAIN); if (!$action || $action == 'request_token') { $request_token = $app->getRequestToken($callback); $_SESSION['request_token_key'] = $request_token->key; $_SESSION['request_token_secret'] = $request_token->secret; $redirect_url = $app->getAuthorizationUrl($request_token); // send user to Yahoo! so he can authorize our example to post on his Meme Header("Location: {$redirect_url}"); } else { if ($action == "authorized") { $request_token = new OAuthConsumer($_SESSION['request_token_key'], $_SESSION['request_token_secret']); $response = $app->getAccessToken($request_token, $_GET['oauth_verifier']); parse_str($response, $params); $access_token = $params['oauth_token']; $access_token_secret = $params['oauth_token_secret']; $_SESSION['ACCESS_TOKEN'] = $access_token; $_SESSION['ACCESS_TOKEN_SECRET'] = $access_token_secret; } else { if ($action == "post") { $token = new OAuthToken($_SESSION['ACCESS_TOKEN'], $_SESSION['ACCESS_TOKEN_SECRET']); $app->token = $token;