示例#1
0
 public function __construct()
 {
     require Mage::getBaseDir('lib') . DS . 'Magegiant' . DS . 'Yahoo' . DS . 'Yahoo.inc';
     error_reporting(E_ALL | E_NOTICE);
     # do not show notices as library is php4 compatable
     ini_set('display_errors', true);
     YahooLogger::setDebug(true);
     YahooLogger::setDebugDestination('LOG');
     // use memcache to store oauth credentials via php native sessions
     ini_set('session.save_handler', 'files');
     session_save_path('/tmp/');
     session_start();
     if (array_key_exists("logout", $_GET)) {
         YahooSession::clearSession();
         //$this->reloadPage();
     }
 }
示例#2
0
 public function __construct()
 {
     try {
         require Mage::getBaseDir('lib') . DS . 'Yahoo' . DS . 'Yahoo.inc';
     } catch (Exception $e) {
     }
     error_reporting(E_ALL | E_NOTICE);
     ini_set('display_errors', true);
     YahooLogger::setDebug(true);
     YahooLogger::setDebugDestination('LOG');
     ini_set('session.save_handler', 'files');
     session_save_path('/tmp/');
     session_start();
     if (array_key_exists("logout", $_GET)) {
         YahooSession::clearSession();
     }
 }
 /**
  * @Yahoo login action
  *
  * Connect Yahoo Using oAuth coonection.
  *
  * @return string URL eiether customer save and loggedin or an error if any occurs
  */
 public function yahoopostAction()
 {
     /**
      * Include @Yahoo library files for oAuth connection
      */
     require 'sociallogin/lib/Yahoo.inc';
     YahooLogger::setDebug(true);
     YahooLogger::setDebugDestination('LOG');
     /**
      *
      * @param string $yahoo_client_id,
      *            $yahoo_client_secret and $yahoo_developer_key
      *            
      *            Using this params setting up the connection to yahoo
      */
     $yahooClientId = Mage::getStoreConfig('sociallogin/yahoo/yahoo_id');
     $yahooClientSecret = Mage::getStoreConfig('sociallogin/yahoo/yahoo_secret');
     $yahooDeveloperKey = Mage::getStoreConfig('sociallogin/yahoo/yahoo_develop');
     $yahooDomain = Mage::getUrl();
     /**
      * Use memcache to store oauth credentials via php native sessions
      *
      * Make sure you obtain application keys before continuing by visiting:<https://developer.yahoo.com/dashboard/createKey.html>
      */
     define('OAUTH_CONSUMER_KEY', "{$yahooClientId}");
     define('OAUTH_CONSUMER_SECRET', "{$yahooClientSecret}");
     define('OAUTH_DOMAIN', "{$yahooDomain}");
     define('OAUTH_APP_ID', "{$yahooDeveloperKey}");
     $para = $this->getRequest()->getParams();
     $data = $this->getRequest()->getParam('fb');
     if (array_key_exists("logout", $para)) {
         YahooSession::clearSession();
         $url = "index.php";
         $this->_redirectUrl($url);
     }
     $hasSession = YahooSession::hasSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
     YahooUtil::current_url();
     if (!$hasSession) {
         $callback = YahooUtil::current_url() . "?in_popup";
         $sessionStore = new NativeSessionStore();
         $authUrl = YahooSession::createAuthorizationUrl(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $callback, $sessionStore);
         if ($authUrl) {
             $this->_redirectUrl($authUrl);
         }
     } else {
         $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
         if ($session) {
             $user = $session->getSessionedUser();
             $profile = $user->getProfile();
             $profile->guid;
             $email = $profile->emails[0]->handle;
             $firstName = $profile->givenName;
             $lastName = $profile->familyName;
             if ($email == '') {
                 Mage::getSingleton('customer/session')->addError($this->__('Yahoo Login connection failed'));
                 $url = Mage::helper('customer')->getAccountUrl();
                 return $this->_redirectUrl($url);
             } else {
                 $this->customerAction($firstName, $lastName, $email, 'Yahoo', $data);
             }
         }
     }
 }
示例#4
0
<?php

// Include the YOS library.
require dirname(__FILE__) . '/../lib/Yahoo.inc';
// debug settings
error_reporting(E_ALL | E_NOTICE);
# do not show notices as library is php4 compatable
ini_set('display_errors', true);
YahooLogger::setDebug(true);
YahooLogger::setDebugDestination('LOG');
// use memcache to store oauth credentials via php native sessions
ini_set('session.save_handler', 'files');
session_save_path('/tmp/');
session_start();
// Make sure you obtain application keys before continuing by visiting:
// https://developer.yahoo.com/dashboard/createKey.html
define('OAUTH_CONSUMER_KEY', '###');
define('OAUTH_CONSUMER_SECRET', '###');
define('OAUTH_DOMAIN', '###');
define('OAUTH_APP_ID', '###');
if (array_key_exists("logout", $_GET)) {
    // if a session exists and the logout flag is detected
    // clear the session tokens and reload the page.
    YahooSession::clearSession();
    header("Location: sampleapp.php");
}
// check for the existance of a session.
// this will determine if we need to show a pop-up and fetch the auth url,
// or fetch the user's social data.
$hasSession = YahooSession::hasSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
if ($hasSession == FALSE) {