/** Create the access token and save to database * */ public function access() { $config = array('requestTokenUrl' => 'http://www.flickr.com/services/oauth/request_token', 'accessTokenUrl' => 'http://www.flickr.com/services/oauth/access_token', 'userAuthorisationUrl' => 'http://www.flickr.com/services/oauth/authorize', 'localUrl' => 'http://beta.finds.org.uk/admin/oauth', 'callbackUrl' => self::CALLBACKURL, 'consumerKey' => $this->_consumerKey, 'consumerSecret' => $this->_consumerSecret, 'version' => '1.0', 'signatureMethod' => 'HMAC-SHA1'); $session = new Zend_Session_Namespace('flickr_oauth'); // build the token request based on the original token and secret $request = new Zend_Oauth_Token_Request(); $request->setToken($session->token)->setTokenSecret($session->secret); unset($session->token); unset($session->secret); $now = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'); $date = new Zend_Date(); $consumer = new Zend_Oauth_Consumer($config); $token = $consumer->getAccessToken(Zend_Controller_Front::getInstance()->getRequest()->getQuery(), $request); $tokens = new OauthTokens(); $tokenRow = $tokens->createRow(); $tokenRow->service = 'flickrAccess'; $tokenRow->accessToken = serialize($token); $tokenRow->created = $now; $tokenRow->save(); }
/** Create a token * * @param array $data */ private function createToken($data) { if ($data) { $data = (object) $data; $tokens = new OauthTokens(); $tokenRow = $tokens->createRow(); $tokenRow->service = 'yahooAccess'; $tokenRow->accessToken = serialize(urldecode($data->oauth_token)); $tokenRow->tokenSecret = serialize($data->oauth_token_secret); $tokenRow->guid = serialize($data->xoauth_yahoo_guid); $tokenRow->sessionHandle = serialize($data->oauth_session_handle); $tokenRow->created = $this->_now; $tokenRow->expires = $this->expires(); $tokenRow->save(); $tokenData = array('accessToken' => $data->oauth_token, 'secret' => $data->oauth_token_secret); return $tokenData; } else { return false; } }
/** Create the access token and save to database * @access public * @return void */ public function access() { $config = array('requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken', 'accessTokenUrl' => 'https://www.google.com/accounts/OAuthGetAccessToken', 'userAuthorisationUrl' => 'https://www.google.com/accounts/OAuthAuthorizeToken', 'localUrl' => Zend_Registry::get('siteurl') . '/admin/oauth', 'callbackUrl' => $this->getCallback(), 'consumerKey' => $this->getConsumerKey(), 'consumerSecret' => $this->getConsumerSecret(), 'version' => '1.0', 'signatureMethod' => 'HMAC-SHA1'); $session = new Zend_Session_Namespace('flickr_oauth'); // build the token request based on the original token and secret $request = new Zend_Oauth_Token_Request(); $request->setToken($session->token)->setTokenSecret($session->secret); unset($session->token); unset($session->secret); $consumer = new Zend_Oauth_Consumer($config); $token = $consumer->getAccessToken(Zend_Controller_Front::getInstance()->getRequest()->getQuery(), $request); $tokens = new OauthTokens(); $tokenRow = $tokens->createRow(); $tokenRow->service = 'googleAccess'; $tokenRow->accessToken = serialize($token); $tokenRow->created = Zend_Date::now()->toString('YYYY-MM-dd HH:mm:ss'); $tokenRow->save(); }