/** * Get data by twitter api url * * @param string $url * @param array $parameters * @param string $format * @return mixed */ private function _get($url, $parameters = array(), $format = 'json') { // Check for curl extension if (!extension_loaded('curl')) { return false; } if (!$this->oauth_setup) { $this->oauth_setup = true; if (!$this->params->get('oauth_token', '') || !$this->params->get('oauth_token_secret', '')) { $this->connection = false; } elseif (false != ($this->connection = modRokTwittieHelper::getOauth($this->params))) { $this->connection->useragent = $this->useragent; $this->connection->connecttimeout = $this->connecttimeout; $this->connection->timeout = $this->timeout; // verify credentials $this->connection->get('account/verify_credentials'); if ($this->connection->http_code != 200) { $this->connection = false; } } } if ($this->connection) { $this->connection->format = $format; $result = $this->connection->get($url, $parameters); if ($this->connection->http_code != 200) { return false; } } else { $ci = curl_init(); curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout); curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($ci, CURLOPT_RETURNTRANSFER, true); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ci, CURLOPT_HEADER, false); curl_setopt($ci, CURLOPT_URL, $this->host . $url . '.' . $format. '?' . OAuthUtil::build_http_query($parameters)); $result = curl_exec($ci); $http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); curl_close ($ci); if ($http_code != 200) { return false; } if ($format == 'json') { $result = json_decode($result); } } return $result; }
break; default: error(); } break; case 'callback': // if the oauth_token is old redirect to the connect page if (isset($_REQUEST['oauth_token']) && $session->get('oauth_token') !== $_REQUEST['oauth_token']) { $session->set('oauth_status', 'oldtoken'); error(); } // create TwitteroAuth object with app key/secret and token key/secret from default phase $connection =& modRokTwittieHelper::getOauth($params, $session->get('oauth_token'), $session->get('oauth_token_secret')); // request access tokens from twitter $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']); // check if token was successfully returned if (!is_array($access_token) || !isset($access_token['oauth_token']) || !isset($access_token['oauth_token_secret'])) { error(); } // update params $params->set('oauth_token', $access_token['oauth_token']); $params->set('oauth_token_secret', $access_token['oauth_token_secret']); $row['params'] = $params->toString();
if ($params->get("load_css", "1") == "1") $document->addStyleSheet(JURI::root(true) ."/modules/mod_roktwittie/css/roktwittie.css"); /* IE 6-7-8 stylesheets */ $iebrowser = modRokTwittieHelper::getBrowser(); if ($iebrowser && $params->get("load_css", "1") == "1") { $style = $document->baseurl."/modules/mod_roktwittie/css/roktwittie-ie$iebrowser"; $check = dirname(__FILE__)."/css/roktwittie-ie$iebrowser"; if (file_exists($check.".css")) $document->addStyleSheet($style.".css"); elseif (file_exists($check.".php")) $document->addStyleSheet($style.".php"); } /* End IE 6-7-8 stylesheets */ if ($params->get("enable_statuses", "1") == "1" || $params->get("enable_usernames", "1") == "1") { $status = modRokTwittieHelper::request($params, $module, "status"); $friends = modRokTwittieHelper::request($params, $module, "friends"); if (is_array($status) && is_array($friends)) { modRokTwittieHelper::loadScripts($params, $module); require(JModuleHelper::getLayoutPath('mod_roktwittie')); } else require(JModuleHelper::getLayoutPath('mod_roktwittie', 'error')); } else { require(JModuleHelper::getLayoutPath('mod_roktwittie', 'error')); }