/** * Get the oatuh adapter using the controller name * * @return ComConnectOauthApiAbstract */ public function getAPI() { if (!isset($this->_api)) { $session = new KConfig(KRequest::get('session.oauth', 'raw', array())); $api = pick($this->getRequest()->server, $session->api); if (!$api) { return null; } //get the api server from the request $this->_api = $this->getService('com://site/connect.oauth.service.' . $api); if (!$this->_consumer) { $name = $this->_api->getName(); $key = get_config_value('com_connect.' . $name . '_key'); $secret = get_config_value('com_connect.' . $name . '_secret'); $query = array('option=com_' . $this->_mixer->getIdentifier()->package, 'view=' . $this->_mixer->getIdentifier()->name, 'server=' . $this->server, 'get=accesstoken'); if ($this->oid) { $query[] = 'oid=' . $this->oid; } $callback = JRoute::_(implode($query, '&'), true); $this->_consumer = new ComConnectOauthConsumer(new KConfig(array('key' => $key, 'secret' => $secret, 'callback_url' => (string) $callback))); } //set the consumer $this->_api->setConsumer($this->_consumer); $this->_api->setToken($session->token); } return $this->_api; }