Çerezler olmadan ve oturum olmadan Zend_Oauth_Consumer kullanmak için en iyi yolu

0 Cevap php

I am developing gadget with tech requirements: "no Cookie, no Session". I have the following code:

<?php

class LinkedIn
{

 private $options;
 private $consumer;
 private $client;
 private $token;


 public function __construct($params)
 {
  // set Zend_Oauth_Consumer options
  $this->options = array(
   'version' => '1.0',
   'localUrl' => $params['localUrl'],
   'callbackUrl' => $params['callbackUrl'],
   'requestTokenUrl' => 'https://api.linkedin.com/uas/oauth/requestToken',
   'userAuthorizationUrl' => 'https://api.linkedin.com/uas/oauth/authorize',
   'accessTokenUrl' => 'https://api.linkedin.com/uas/oauth/accessToken',
   'consumerKey' => $params['apiKey'],
   'consumerSecret' => $params['secretKey']
  );

  // instanciate Zend_Oauth_Consumer class
  require_once 'Zend/Loader.php';
  Zend_Loader::loadClass('Zend_Oauth_Consumer');
  $this->consumer = new Zend_Oauth_Consumer($this->options);
 }


 public function connect()
 {
  // Start Session to be able to store Request Token &amp; Access Token
  session_start ();

  if (!isset ($_SESSION ['ACCESS_TOKEN'])) {
   // We do not have any Access token Yet
   if (! empty ($_GET)) {
 // SECTION_IF
    // But We have some parameters passed throw the URL

    // Get the LinkedIn Access Token
    $this->token = $this->consumer->getAccessToken ($_GET, unserialize($_SESSION ['REQUEST_TOKEN']));

    // Store the LinkedIn Access Token
    $_SESSION ['ACCESS_TOKEN'] = serialize ($this->token);
   } else {
 // SECTION_ELSE
    // We have Nothing

    // Start Requesting a LinkedIn Request Token
    $this->token = $this->consumer->getRequestToken ();

    // Store the LinkedIn Request Token
    $_SESSION ['REQUEST_TOKEN'] = serialize ($this->token);

    // Redirect the Web User to LinkedIn Authentication Page
    $this->consumer->redirect ();
   }
  } else {
   // We've already Got a LinkedIn Access Token

   // Restore The LinkedIn Access Token
   $this->token = unserialize ($_SESSION ['ACCESS_TOKEN']);

  }

  // Use HTTP Client with built-in OAuth request handling
  $this->client = $this->token->getHttpClient($this->options);

 }
}

Bu mükemmel çalışıyor. Ama REQUEST_TOKEN OTURUM saklanır. Onu nasıl SECTION_IF içinde SECTION_ELSE içinde dize sorgulamak ve onu geri almak için koyabilirsiniz? Tüm tavsiye için teşekkürler.

0 Cevap