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(); } }
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(); } }
<?php // Include the YSP PHP SDK to access the library. // You need to change the path of Yahoo.inc. include_once "lib/Yahoo.inc"; // Define constants to store your Consumer Key and Consumer Secret. define("CONSUMER_KEY", "<your consumer key>"); define("CONSUMER_SECRET", "<your consumer secret>"); // Enable debugging. Errors are reported to Web server's error log. YahooLogger::setDebug(true); // Initializes session and redirects user to Yahoo! to sign in and // then authorize app $yahoo_session = YahooSession::requireSession(CONSUMER_KEY, CONSUMER_SECRET); if ($yahoo_session == NULL) { fatal_error("yahoo_session"); } $data_orig = $yahoo_session->query('select * from social.connections.updates where guid=me'); $updates = $data_orig->query->results->update; $data = $yahoo_session->query('select * from google.translate where q in (select title from social.connections.updates where guid=me) and target="hi"'); foreach ($data->query->results->translatedText as $i => $update) { echo "<div style='height:70px;padding-left:10px;'><div style='float:left;padding:2px;'> <a href='" . $updates[$i]->profile_profileUrl . "'><img style='border:0;' src ='" . $updates[$i]->profile_displayImage . "'> </a></div><div> <a href='" . $updates[$i]->profile_profileUrl . "'>" . $updates[$i]->profile_nickname . "</a> {$update} </div></div>"; }
/** * @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); } } } }