コード例 #1
0
 public function loginAction()
 {
     if ($this->getSession()->isLoggedIn()) {
         return $this->_redirectUrl();
     }
     $connection = new LinkedInOAuth(Mage::getStoreConfig('gomage_social/linkedin/id'), Mage::getStoreConfig('gomage_social/linkedin/secret'));
     $callback_params = array('_secure' => true);
     if ($this->getRequest()->getParam('gs_url', '')) {
         $callback_params['gs_url'] = $this->getRequest()->getParam('gs_url');
     }
     $callback_url = Mage::getUrl('gomage_social/linkedin/callback', $callback_params);
     $request_token = $connection->getRequestToken($callback_url);
     switch ($connection->http_code) {
         case 200:
             Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
             Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
             $url = $connection->getAuthorizeURL($request_token['oauth_token']);
             return $this->_redirectUrl($url);
             break;
         default:
             $this->getSession()->addError($this->__('Could not connect to LinkedIn. Refresh the page or try again later.'));
     }
     return $this->_redirectUrl();
 }
コード例 #2
0
ファイル: oauth-inc.php プロジェクト: highfidelity/love
        }
        echo "</ul>";
        echo "<input type='checkbox' style='margin-top: 5px;'";
        echo $front->getUser()->getLinkedin_share() == '1' ? 'checked="checked"' : '';
        echo " id='linkedin_status' name='linkedin_status' value='Y' />";
        echo "Send my weekly love stats to my LinkedIn status. ex: 2 love from 2 people.";
        echo "</div>";
    }
}
?>

    <?php 
$requestlink = "";
if (empty($access_token) && !empty($request_token)) {
    $to = new LinkedInOAuth(LINKEDIN_API_KEY_PUBLIC, LINKEDIN_API_KEY_PRIVATE);
    $requestlink = $to->getAuthorizeURL($request_token);
}
?>
    <div id="sync_linkedin" class="settingsbutton <?php 
echo !empty($access_token) ? 'hide"' : '"';
?>
 onclick="<?php 
echo "location.href='{$requestlink}';";
?>
" >Link profile</div>
    
    <div id="revoke_linkedin" class="settingsbutton <?php 
echo !empty($access_token) ? '"' : 'hide"';
?>
>Revoke</div>
コード例 #3
0
 public function get_linkein_auth_link()
 {
     $requestlink = "";
     //LinkedIn lib
     require_once xoousers_path . "libs/linkedin/oauth/linkedinoauth.php";
     $oauthstate = $this->get_linkedin_oauth_token();
     $tokenpublic = $oauthstate['request_token'];
     $to = new LinkedInOAuth($this->get_option('social_media_linkedin_api_public'), $this->get_option('social_media_linkedin_api_private'));
     $requestlink = $to->getAuthorizeURL($tokenpublic, $this->get_current_url());
     return $requestlink;
 }
コード例 #4
0
ファイル: SocialAuth.php プロジェクト: anvnguyen/Goteo
 /**
  * Autentica con LinkedIn, redirige a LinkedIn para que el usuario acepte
  * */
 public function authenticateLinkedin()
 {
     try {
         //do the authentication:
         //get public tokens
         $to = new \LinkedInOAuth($this->linkedin_id, $this->linkedin_secret);
         // This call can be unreliable for some providers if their servers are under a heavy load, so
         // retry it with an increasing amount of back-off if there's a problem.
         $maxretrycount = 1;
         $retrycount = 0;
         while ($retrycount < $maxretrycount) {
             $tok = $to->getRequestToken($this->callback_url);
             if (isset($tok['oauth_token']) && isset($tok['oauth_token_secret'])) {
                 break;
             }
             $retrycount += 1;
             sleep($retrycount * 5);
         }
         if (empty($tok['oauth_token']) || empty($tok['oauth_token_secret'])) {
             $this->last_error = "oauth-token-request-error";
             return false;
         }
         //en linkedin hay que guardar los token de autentificacion para usarlos
         //despues para obtener los tokens de acceso,
         $_SESSION['linkedin_token'] = $tok;
         //set URL
         $url = $to->getAuthorizeURL($tok['oauth_token']);
         header("Location: {$url}");
         exit;
     } catch (Exception $e) {
         $this->last_error = $e->getMessage() . " 1/ " . get_class($e);
         return false;
     }
     return true;
 }