예제 #1
0
파일: tests.php 프로젝트: jasherai/libwebta
 function testNET_HTTP_HTTPClient()
 {
     $robot = new HTTPClient();
     // connect to url
     $res = $robot->Fetch("http://webta.net");
     $this->assertTrue($res, "Can't fetch url");
     /* end of tests */
 }
예제 #2
0
파일: tests.php 프로젝트: rchicoria/epp-drs
 function testData_XML_RSS_RSSReader()
 {
     $http = new HTTPClient();
     // rss 2.0
     $url = 'http://aggressiva.livejournal.com/data/rss';
     $http->SetTimeouts(30, 15);
     $xml = $http->Fetch($url);
     $Reader = new RSSReader();
     $Reader->Parse($xml);
     $data = $Reader->GetData();
     $this->assertTrue($data['channel'], "No channel found");
     $this->assertTrue($data['item']['pubdate'], "No items found");
 }
예제 #3
0
		/**
		 * Get blog entries from myspace account
		 * 
		 * @var int friend account number (if not default)
		 */
		function GetBlogEntries($accountid)
		{
			if (!$accountid) $accountid = $this->AccountID;
			
			$blog_page = sprintf(self::BLOG_URL, $accountid);
			
			$http = new HTTPClient();
			$http->SetTimeouts(60, 30);
			$http->Fetch($blog_page);
			
			if (preg_match("/<title>[^<]*302 Found[^<]*<\/title>/msi", $http->Result))
			{
				$blog_page = sprintf(self::BLOG_URL_SIMPLE, $accountid);
				
				$http = new HTTPClient();
				$http->SetTimeouts(60, 30);
				$http->Fetch($blog_page);
			}
			
			$blog_xml = $http->Result;
			
			$Reader = new RSSReader();
			$Reader->Parse($blog_xml);
			$data = $Reader->GetData();

			if (!$data) 
				return false;
			
			$blogs = array();
			
			foreach((array)$data['item']['title'] as $key => $subject)
			{
				$timestamp = strtotime($data['item']['pubdate'][$key]);
				
				array_push($blogs, array(
					'date'		=> date("Y-m-d", $timestamp),
					'subject'	=> $subject,
					'category'	=> "",
					'content'	=> $data['item']['description'][$key],
					'time'		=> date("H:i", $timestamp),
					'comments'	=> "",
					'timestamp' => $timestamp
				));
				
			} 
			
			return $blogs;
			
		}
예제 #4
0
		/**
		 * Get blog entries from myspace account
		 * 
		 * @var int friend account number (if not default)
		 */
		function GetBlogEntries($accountid = 0)
		{
			if (!$accountid) $accountid = $this->AccountID;
			
			$blog_page = sprintf(self::BLOG_ATOM_URL, $accountid);

			$http = new HTTPClient();
			$http->SetTimeouts(60, 30);
			$http->Fetch($blog_page);
			$blog_xml = $http->Result;

			$Reader = new RSSReader();
			$Reader->Parse($blog_xml);
			$data = $Reader->GetData();

			if (!$data) 
				return false;
			
			$blogs = array();
			
			foreach($data['item']['title'] as $key => $subject)
			{
				$timestamp = strtotime($data['item']['published'][$key]);
				
				array_push($blogs, array(
					'date'		=> date("Y-m-d", $timestamp),
					'subject'	=> $subject,
					'category'	=> "",
					'content'	=> $data['item']['content'][$key],
					'time'		=> date("H:i", $timestamp),
					'comments'	=> "",
					'timestamp' => $timestamp
				));
				
			} 
			
			return $blogs;
			
		}
예제 #5
0
		private function SendRequest($request)
		{
		    $HTTPClient = new HTTPClient();
		    $params = array("APACScommand" => "NewRequest", "Data" => $request);		    
		    
		    return $HTTPClient->Fetch($this->URL, $params, true);
		}