public function hasSession() { $consumerKey = $this->getConsumerKey(); $consumerSecret = $this->getConsumerSecret(); $appId = $this->getAppId(); return YahooSession::hasSession($consumerKey, $consumerSecret, $appId); }
public function saveAction() { require 'Yahoo/Yahoo.inc'; $helper = Mage::helper('referralreward'); //YahooLogger::setDebug(true); //YahooLogger::setDebugDestination('LOG'); define('OAUTH_CONSUMER_KEY', $helper->storeConfig('yahoo/key')); define('OAUTH_CONSUMER_SECRET', $helper->storeConfig('yahoo/secret')); define('OAUTH_DOMAIN', Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); define('OAUTH_APP_ID', $helper->storeConfig('yahoo/appid')); $hasSession = YahooSession::hasSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID); if ($hasSession == FALSE) { $callback = YahooUtil::current_url() . "?in_popup"; $sessionStore = new NativeSessionStore(); $authUrl = YahooSession::createAuthorizationUrl(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $callback, $sessionStore); header("Location: " . $authUrl); exit; } else { $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID); if ($session) { $user = $session->getSessionedUser(); //$profile = $user->getProfile(); $contacts = $user->getContactSync(); if ($contacts) { $contacts = $this->XmltoArray($contacts); $names = array(); $emails = array(); foreach ($contacts['contactsync']['contacts'] as $key => $profileContact) { foreach ($profileContact['fields'] as $contact) { $emails[] = $contact['value']; $names[] = ''; } } YahooSession::clearSession(); $customer_id = (int) $this->_getSession()->getId(); $count = Mage::getModel('referralreward/friends')->saveFriends($customer_id, $emails, $names); if ($count['enable']) { if ($count['enable'] > 1) { $this->_getSession()->addSuccess($this->__('%s have been added', $count['enable'])); } else { $this->_getSession()->addSuccess($this->__('%s has been added', $count['enable'])); } } if ($count['disable']) { $this->_getSession()->addSuccess($this->__('%s already registered', $count['disable'])); } if ($count['enable'] == 0 && $count['disable'] == 0) { $this->_getSession()->addError($this->__("no emails were added")); } } else { $this->_getSession()->addError($this->__("no emails were added")); } } echo "<script>\n window.opener.location.reload(true);\n window.close();\n </script>"; } }
public function hasSession() { return YahooSession::hasSession($this->_getConsumerKey(), $this->_getConsumerSecret(), $this->_getAppId()); }
/** * @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); } } } }
// 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) { // create the callback url, $callback = YahooUtil::current_url() . "?in_popup"; // pass the credentials to get an auth url. // this URL will be used for the pop-up. $auth_url = YahooSession::createAuthorizationUrl(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $callback); } else { // pass the credentials to initiate a session $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID); // if the in_popup flag is detected, // the pop-up has loaded the callback_url and we can close this window. if (array_key_exists("in_popup", $_GET)) { close_popup(); exit; }
function ShareYahoo($text, $userID, $linktext, $linkurl) { App::import('Vendor', 'Yahoo', array('file' => 'yahoo/Yahoo.inc')); $Setting = ClassRegistry::Init("Setting"); $settings = $Setting->find('first'); $settings = $settings['Setting']; $hasSession = YahooSession::hasSession($settings['yahoo_consumer_key'], $settings['yahoo_consumer_secret'], $settings['yahoo_app_id']); if ($hasSession != FALSE) { $session = YahooSession::requireSession($settings['yahoo_consumer_key'], $settings['yahoo_consumer_secret'], $settings['yahoo_app_id']); $user = $session->getSessionedUser(); // create an unique hash of the update data using md5 $suid = md5($text . $linktext . $linkurl . time()); // insert the update... $user->insertUpdate($suid, $text, $linkurl, $linktext); return true; } return false; }
session_start(); // Make sure you obtain application keys before continuing by visiting: // https://developer.yahoo.com/dashboard/createKey.html define("CONSUMER_KEY", "dj0yJmk9WUxPUkhFUWxISWpvJmQ9WVdrOWFYWmhTVzVDTXpBbWNHbzlNVGt4TmpJNU1EazROdy0tJnM9Y29uc3VtZXJzZWNyZXQmeD01Ng--"); define("CONSUMER_SECRET", "f893cf549be5cb37f83b1414e2ff212df2ea4c18"); define("APP_ID", "ivaInB30"); 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(CONSUMER_KEY, CONSUMER_SECRET, APP_ID); if ($hasSession == FALSE) { // create the callback url, $callback = YahooUtil::current_url() . "?in_popup"; // pass the credentials to get an auth url. // this URL will be used for the pop-up. $auth_url = YahooSession::createAuthorizationUrl(CONSUMER_KEY, CONSUMER_SECRET, $callback); } else { // pass the credentials to initiate a session $session = YahooSession::requireSession(CONSUMER_KEY, CONSUMER_SECRET, APP_ID); // if the in_popup flag is detected, // the pop-up has loaded the callback_url and we can close this window. if (array_key_exists("in_popup", $_GET)) { close_popup(); exit; }