Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 3
0
<?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>";
}
Ejemplo n.º 4
0
 /**
  * @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);
             }
         }
     }
 }
Ejemplo n.º 5
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) {
Ejemplo n.º 6
0
 /**
  * Checks to see if the code and headers indicate an expired OAuth token.
  * If so, requests a new one.
  *
  * @private
  */
 function checkExpired($code, $headerParser) {
     if ($code != 401) return; // HTTP Unauthorized
     $authenticateHeader = $headerParser->get('WWW-Authenticate');
     if (!$authenticateHeader) return;
     if (!preg_match('/oauth_problem="([^"]+)"/', $authenticateHeader, $match)) return;
     $oauth_problem = $match[1];
     if ($oauth_problem == 'token_expired') {
         YahooLogger::error('Access token expired. Please fetch a new one');
     }
     if ($oauth_problem == 'consumer_key_unknown') {
         YahooLogger::error('Consumer Key unkown.  Please check that the Consumer Key is valid.');
     }
     if ($oauth_problem == 'additional_authorization_required') {
         YahooLogger::error('The app identified by this Consumer Key is not authorized to access this resource.  Authorization is defined under Access Scopes on the application\'s settings page.');
     }
 }