From 6d63838c2e56938e88cc59d1e0a62b651ed74f96 Mon Sep 17 00:00:00 2001 From: nickw Date: Thu, 8 Apr 2010 19:47:44 +0000 Subject: Moving Twitter Service plugin from core into the plugins directory. git-svn-id: http://code.elgg.org/elgg/trunk@5670 36083f99-b078-4883-b0ff-0f9b5a30f544 --- .../vendors/twitter/twitter.class.php | 142 --------------------- 1 file changed, 142 deletions(-) delete mode 100644 mod/twitterservice/vendors/twitter/twitter.class.php (limited to 'mod/twitterservice/vendors/twitter/twitter.class.php') diff --git a/mod/twitterservice/vendors/twitter/twitter.class.php b/mod/twitterservice/vendors/twitter/twitter.class.php deleted file mode 100644 index 457bede4c..000000000 --- a/mod/twitterservice/vendors/twitter/twitter.class.php +++ /dev/null @@ -1,142 +0,0 @@ -user = $user; - $this->pass = $pass; - } - - - - /** - * Sends message to the Twitter. - * @param string message encoded in UTF-8 - * @return boolean TRUE on success or FALSE on failure - */ - public function send($message) - { - $result = $this->httpRequest( - 'https://twitter.com/statuses/update.xml', - array('status' => $message) - ); - return strpos($result, '') !== FALSE; - } - - - - /** - * Returns the 20 most recent statuses posted from you and your friends (optionally). - * @param bool with friends? - * @return SimpleXMLElement - * @throws Exception - */ - public function load($withFriends, $since = '') - { - $line = $withFriends ? 'friends_timeline' : 'user_timeline'; - $url = "http://twitter.com/statuses/$line/$this->user.xml"; - //if (!empty($since)) - // $url .= "?since=" . urlencode($since); - $feed = $this->httpRequest($url); - if ($feed === FALSE) { - throw new Exception('Cannot load channel.'); - } - - $xml = new SimpleXMLElement($feed); - if (!$xml || !$xml->status) { - throw new Exception('Invalid channel.'); - } - - return $xml; - } - - - - /** - * Process HTTP request. - * @param string URL - * @param array post data - * @return string|FALSE - */ - private function httpRequest($url, $post = NULL) - { - /* - if (!$post && self::$cacheDir) { - $cacheFile = self::$cacheDir . '/twitter.' . md5($url) . '.xml'; - if (@filemtime($cacheFile) + self::$cacheExpire > time()) { - return file_get_contents($cacheFile); - } - } - */ - - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $url); - // curl_setopt($curl, CURLOPT_USERPWD, "$this->user:$this->pass"); - curl_setopt($curl, CURLOPT_HEADER, FALSE); - curl_setopt($curl, CURLOPT_TIMEOUT, 20); - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); - if ($post) { - curl_setopt($curl, CURLOPT_USERPWD, "$this->user:$this->pass"); - curl_setopt($curl, CURLOPT_POST, TRUE); - curl_setopt($curl, CURLOPT_POSTFIELDS, $post); - } - curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); // no echo, just return result - $result = curl_exec($curl); - $ok = curl_errno($curl) === 0 && curl_getinfo($curl, CURLINFO_HTTP_CODE) === 200; - - if (!$ok) { - if (isset($cacheFile)) { - $result = @file_get_contents($cacheFile); - if (is_string($result)) { - return $result; - } - } - return FALSE; - } - - /* - if (isset($cacheFile)) { - file_put_contents($cacheFile, $result); - } - */ - - return $result; - } - -} -- cgit v1.2.3