rss관련 질문입니다.

http://ecpc.kr/sub/06_09.html
위사이트를 보시면 foreach문이랑..fsockopen 함수에서 문제가 있는거같은데..도통모르겠네요..
----------------------------------------------------------------------------------------
if($http = @fsockopen($host, 80, $errno, $errstr, 10 )){
// make the request
fwrite($http, $request);
// read in for max 10 seconds
$timeout = time() + 10;
while(time() < $timeout && !feof($http)) {
$response .= fgets($http, 4096);}
// split on two newlines
list($header, $xml) = preg_split("/\r?\n\r?\n/", $response, 2);
// get the status
if(preg_match("/^HTTP\/[0-9\.]+\s+(\d+)\s+/", $header, $matches)){
$status = $matches[1];
// if 200 OK
if($status == 200){
// create the parser
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
// parse!
xml_parse($xml_parser, trim($xml), true) or $g_rss_array[errors][] = xml_error_string(xml_get_error_code($xml_parser)) . " at line " . xml_get_current_line_number($xml_parser);
// free parser
xml_parser_free($xml_parser);
} else {
$g_rss_array[errors][] = "Can't get feed: HTTP status code $status";
}
} else {
$g_rss_array[errors][] = "Can't get status from header";
}
} else {
echo "<B><font color=#FF5F00>현재 연결 할 수 없습니다.<br />RSS주소또는서버문제 잠시 후 다시 시도해 보세요.</font></B><br />"; }

--------------------------------------------------------------------------------------
foreach ($rss_array['items'] as $item) {
$rss_list[title][$cnt] = conv_subject($item[title], $subject_len, "…");//제목
$rss_list[description][$cnt] = $item[description];//내용
$rss_list[link][$cnt] = $item[link];//링크
$rss_list[tag][$cnt] = $item[tag];//링크
$rss_list[pubdate][$cnt] = timeconv($item[pubdate]);//날짜
$rss_list[date][$cnt] = timeconv($item[cd_date]);//날짜 //취소
$cnt++;

} //foreach

-----------------------------------------------------------------------------------
위코드에서 걸리는거 같은데..확인 좀 부탁드릴께요.ㅠㅠ
|

댓글 1개

$rss_array['items'] 이부분의 값이 없는듯하네요
xml 을 제대로 읽어오는지부터 확인해주세요~
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
14년 전 조회 1,032
14년 전 조회 4,342
14년 전 조회 983
14년 전 조회 972
14년 전 조회 823
14년 전 조회 1,559
14년 전 조회 1,646
14년 전 조회 679
14년 전 조회 2,268
14년 전 조회 1,160
14년 전 조회 1,643
14년 전 조회 985
14년 전 조회 998
14년 전 조회 1.5만
14년 전 조회 1,007
14년 전 조회 1,480
14년 전 조회 1,632
14년 전 조회 1,589
14년 전 조회 1,756
14년 전 조회 807