randomsai Posted April 1, 2010 Share Posted April 1, 2010 i need to parse a URL and read the some of the contents of the XML data. i am getting a lot of problems trying to read the URL. i can get it open, but that is as far as i go. here is the code below: FUNCTION parse() { IF (!($fp = @FOPEN($this->file, "r"))) { $this->error = "Could not open RSS source \"$this->file\"."; RETURN FALSE; } WHILE ($data = FREAD($fp, 4096)) { IF (!XML_PARSE($this->xml_parser, $data, FEOF($fp))) { $this->error = SPRINTF("XML error: %s at line %d.", XML_ERROR_STRING(XML_GET_ERROR_CODE($this->xml_parser)), XML_GET_CURRENT_LINE_NUMBER($this->xml_parser)); RETURN FALSE; } } XML_PARSER_FREE($this->xml_parser); RETURN TRUE; } } $e =0; $con1 = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("advisorysuite") or die(mysql_error()); $data = mysql_query("SELECT * FROM currentnewssource ORDER BY KEYNUM ASC") or die(mysql_error()); mysql_close($con1); while ($info = mysql_fetch_array( $data )) { $url = $info['URL']; $auth = base64_encode('807004261:19880609'); $aContext = array( 'http' => array( 'proxy' => 'tcp://192.168.224.5:8080', 'request_fulluri' => true, 'header' => "Proxy-Authorization: Basic $auth", ), ); $cxContext = stream_context_create($aContext); $sFile = file_get_contents($url, False, $cxContext); $lengg = strlen($sFile); if ( $lengg != 0) { if ($e==0) { $rss = NEW rss_parser(); $rss->file = "$sFile"; $rss->parse() or DIE($rss->error); IF ($rss->error) PRINT $rss->error; PRINT_R($rss->channel); $e++; i think the problem is with the parse function. Link to comment https://forums.phpfreaks.com/topic/197292-need-to-parse-url-via-proxy-and-authentication/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.