public function signin() { $oauthapp = new \YahooOAuthApplication(Ntentan::$config['social.yahoo.consumer_key'], Ntentan::$config['social.yahoo.consumer_secret'], Ntentan::$config['social.yahoo.app_id'], Ntentan::$config['social.yahoo.redirect_uri']); if (!isset($_REQUEST['openid_mode'])) { Ntentan::redirect($oauthapp->getOpenIDUrl($oauthapp->callback_url), true); die; } if ($_REQUEST['openid_mode'] == 'id_res') { $requestToken = new \YahooOAuthRequestToken($_REQUEST['openid_oauth_request_token'], ''); $_SESSION['yahoo_oauth_request_token'] = $requestToken->to_string(); $oauthapp->token = $oauthapp->getAccessToken($requestToken); $_SESSION['yahoo_oauth_access_token'] = $oauthapp->token->to_string(); } $profile = $oauthapp->getProfile()->profile; if (is_object($profile)) { if (is_array($profile->emails)) { foreach ($profile->emails as $email) { if ($email->primary == 'true') { $email = $email->handle; break; } } } return array('firstname' => $profile->givenName, 'lastname' => $profile->familyName, 'key' => "yahoo_{$profile->guid}", 'avatar' => $profile->image->imageUrl, 'email' => $email, 'email_confirmed' => true); } die('Failed'); }
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. **/ require_once dirname(__FILE__) . '/../common.inc.php'; $oauthapp = new YahooOAuthApplication(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID, OAUTH_DOMAIN); // handle openid/oauth if (isset($_REQUEST['openid_mode'])) { switch ($_REQUEST['openid_mode']) { case 'discover': case 'checkid_setup': case 'checkid_immediate': // handle yahoo simpleauth popup + redirect to yahoo! open id with open app oauth request header('Location: ' . $oauthapp->getOpenIDUrl(isset($_REQUEST['popup']) ? $oauthapp->callback_url . '?close=true' : $oauthapp->callback_url)); exit; break; case 'id_res': // validate claimed open id // extract approved request token from open id response $request_token = new YahooOAuthRequestToken($_REQUEST['openid_oauth_request_token'], ''); $_SESSION['yahoo_oauth_request_token'] = $request_token->to_string(); // exchange request token for access token $oauthapp->token = $oauthapp->getAccessToken($request_token); // store access token for later $_SESSION['yahoo_oauth_access_token'] = $oauthapp->token->to_string(); break; case 'cancel': unset($_SESSION['yahoo_oauth_access_token']); unset($_REQUEST['openid_mode']);
$oauthapp = new YahooOAuthApplication(YAHOO_OAUTH_CONSUMER_KEY, YAHOO_OAUTH_CONSUMER_SECRET, YAHOO_OAUTH_APP_ID, YAHOO_OAUTH_DOMAIN); if (!isset($_REQUEST['openid_mode'])) { $_REQUEST['openid_mode'] = 'discover'; } $yahoo_feed = ''; if (isset($_REQUEST["yahoo_feed"])) { $yahoo_feed = 1; } // handle openid/oauth if (isset($_REQUEST['openid_mode'])) { switch ($_REQUEST['openid_mode']) { case 'discover': case 'checkid_setup': case 'checkid_immediate': // handle yahoo simpleauth popup + redirect to yahoo! open id with open app oauth request header('Location: ' . $oauthapp->getOpenIDUrl($oauthapp->callback_url . '?provider=yahoo&close=true&yahoo_feed=' . $yahoo_feed)); exit; break; case 'id_res': // validate claimed open id // extract approved request token from open id response $request_token = new YahooOAuthRequestToken($_REQUEST['openid_oauth_request_token'], ''); $email_address = $_REQUEST['openid_ax_value_email']; $_SESSION['yahoo_oauth_request_token'] = $request_token->to_string(); // exchange request token for access token $oauthapp->token = $oauthapp->getAccessToken($request_token); // store access token for later $_SESSION['yahoo_oauth_access_token'] = $oauthapp->token->to_string(); $auth_token = $oauthapp->token->to_string(); break; case 'cancel':