อยากถามเกี่ยวกับ rss ครับ

เริ่มโดย youcanberich, 03 ธันวาคม 2006, 01:49:37

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

youcanberich

ผมอยากจะให้ rss สามารถเลือกหัวข้อได้อะครับว่าจะแสดงกี่หัวข้อ แล้วมันสามารถเปลี่ยนฟร้อนตัวหนังสือได้มั้ยครับ ใครแก้เป็นช่วยแก้ให้หน่อยครับ จนปัญญาจริงๆ

อ้างถึง<?php

/*
Created by Global Syndication's RSS Parser
hxxp://www.globalsyndication.com/rss-parser
*/

set_time_limit(0);

$file = "http://news.search.yahoo.com/news/rss?p=web+hosting&ei=UTF-8&fl=0&x=wrt";

$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;

function startElement($parser, $name, $attrs) {
     global $rss_channel, $currently_writing, $main;
     switch($name) {
        case "RSS":
        case "RDF:RDF":
        case "ITEMS":
           $currently_writing = "";
           break;
        case "CHANNEL":
           $main = "CHANNEL";
           break;
        case "IMAGE":
           $main = "IMAGE";
           $rss_channel["IMAGE"] = array();
           break;
        case "ITEM":
           $main = "ITEMS";
           break;
        default:
           $currently_writing = $name;
           break;
     }
}

function endElement($parser, $name) {
     global $rss_channel, $currently_writing, $item_counter;
     $currently_writing = "";
     if ($name == "ITEM") {
        $item_counter++;
     }
}

function characterData($parser, $data) {
  global $rss_channel, $currently_writing, $main, $item_counter;
  if ($currently_writing != "") {
     switch($main) {
        case "CHANNEL":
           if (isset($rss_channel[$currently_writing])) {
              $rss_channel[$currently_writing] .= $data;
           } else {
              $rss_channel[$currently_writing] = $data;
           }
           break;
        case "IMAGE":
           if (isset($rss_channel[$main][$currently_writing])) {
              $rss_channel[$main][$currently_writing] .= $data;
           } else {
              $rss_channel[$main][$currently_writing] = $data;
           }
           break;
        case "ITEMS":
           if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
              $rss_channel[$main][$item_counter][$currently_writing] .= $data;
           } else {
              $rss_channel[$main][$item_counter][$currently_writing] = $data;
           }
           break;
     }
  }
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
  die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
  if (!xml_parse($xml_parser, $data, feof($fp))) {
     die(sprintf("XML error: %s at line %d",
              xml_error_string(xml_get_error_code($xml_parser)),
              xml_get_current_line_number($xml_parser)));
  }
}
xml_parser_free($xml_parser);

// output HTML
print ("<div class=\"channelname\">" . $rss_channel["TITLE"] . "</div>");
print ("<div class=\"channeldescription\">" . $rss_channel["DESCRIPTION"] . "</div><br />");
if (isset($rss_channel["ITEMS"])) {
  if (count($rss_channel["ITEMS"]) > 0) {
     for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
        if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
        print ("\n<div class=\"itemtitle\"><a href=\"" . $rss_channel["ITEMS"][$i]["LINK"] . "\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a></div>");
        } else {
        print ("\n<div class=\"itemtitle\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</div>");
        }
         print ("<div class=\"itemdescription\">" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br />");       }
  } else {
     print ("<b>There are no articles in this feed.</b>");
  }
}
//print ("<span style="font-size:xx-small;"><a href=\"http://www.globalsyndication.com/rss-parser\" style=\"color:white;\">Free PHP RSS Parser</a> - <a href=\"http://www.globalsyndication.com/rss-hosting\" style=\"color:white\">RSS Newsfeed Hosting</a></span>");
?>
[direct=http://www.iheartpassiveincome.com/]อยากรู้ว่าผมทำเงินวันละ $1000 ได้ยังไง คลิ๊ก![/direct]
[direct=http://www.iheartpassiveincome.com/]ผมจะสอนให้คุณหารายได้แบบยั่งยืนบนโลกออนไลน์ รับประกันคุณทำได้แน่นอน[/direct]
[direct=http://www.iheartpassiveincome.com/]เหนื่อยกับการปั่นเว็บใช่มั้ย อยากทำเงินวันละ $100 และไม่ต้องลุ้นโดนแบนรายวัน ผมมีทางออกให้ คลิ๊กครับ![/direct]

abac401

ขอฝาก ถามด้วยครับ  กรณีเราทำ Rss เองแล้วเอาไป Submit เราSubmitได้ทุกวันเลยไหมครับโดยเปลี่ยนเนื้อหาไปเรื่อยๆ

totiz

แก้ที่บรรทัด 99 for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
เป็น for($i = 0;$i < 3;$i++) { 3 คือ ให้แสดง 3 บทความ
วิธีเปลี่ยน font ก็ ใส่ <font> ครอบ ตรง $rss_channel["ITEMS"][$i]["TITLE"] กับ $rss_channel["ITEMS"][$i]["DESCRIPTION"]
เช่น บรรทัด 105
print ("<div class=\"itemdescription\"><font face='Courier New, Courier, monospace'>" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</font></div><br />");

ถ้าอ่านแล้วงง ถามได้นะ

iamnewbies

$file = "http://news.search.yahoo.com/news/rss?p=web+hosting&ei=UTF-8&fl=0&x=wrt";



เปลี่ยน  web+hosting   เป็นอื่นๆๆ

เช่น

adsense
ebay
make+money
adsense+make+money
credit+card
pet+dog+cat
car+insurance
unlimited+domain+hosting
hosting+unlimited+domain

ก็จะได้เป้น

สังเกตุดูนะ



$file = "http://news.search.yahoo.com/news/rss?p=adsense&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=google+adwords&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=pay+per+click&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=make+money&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=adsense+make+money&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=download+music&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=free+weh+hosting&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=condom&ei=UTF-8&fl=0&x=wrt";
$file = "http://news.search.yahoo.com/news/rss?p=free+email&ei=UTF-8&fl=0&x=wrt";

ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ

youcanberich

ok ครับ เดี๋ยวลองไปแก้ดู
[direct=http://www.iheartpassiveincome.com/]อยากรู้ว่าผมทำเงินวันละ $1000 ได้ยังไง คลิ๊ก![/direct]
[direct=http://www.iheartpassiveincome.com/]ผมจะสอนให้คุณหารายได้แบบยั่งยืนบนโลกออนไลน์ รับประกันคุณทำได้แน่นอน[/direct]
[direct=http://www.iheartpassiveincome.com/]เหนื่อยกับการปั่นเว็บใช่มั้ย อยากทำเงินวันละ $100 และไม่ต้องลุ้นโดนแบนรายวัน ผมมีทางออกให้ คลิ๊กครับ![/direct]

youcanberich

อ้างถึงจาก: abac401ขอฝาก ถามด้วยครับ  กรณีเราทำ Rss เองแล้วเอาไป Submit เราSubmitได้ทุกวันเลยไหมครับโดยเปลี่ยนเนื้อหาไปเรื่อยๆ
ผมว่าน่าจะได้นะครับ แต่หัวข้อข่าวควรจะไม่ซำ้กับของเก่าอะครับ เช่น ทำไป 5 หัวข้อ
พอ อัพใหม่เปลี่ยนแค่หัวข้อเดียวที่เหลือเหมือนเดิม ยังงี้ไม่รู้ครับ ที่ผมทำก็ เปลี่ยนทั้งหมดเลย
[direct=http://www.iheartpassiveincome.com/]อยากรู้ว่าผมทำเงินวันละ $1000 ได้ยังไง คลิ๊ก![/direct]
[direct=http://www.iheartpassiveincome.com/]ผมจะสอนให้คุณหารายได้แบบยั่งยืนบนโลกออนไลน์ รับประกันคุณทำได้แน่นอน[/direct]
[direct=http://www.iheartpassiveincome.com/]เหนื่อยกับการปั่นเว็บใช่มั้ย อยากทำเงินวันละ $100 และไม่ต้องลุ้นโดนแบนรายวัน ผมมีทางออกให้ คลิ๊กครับ![/direct]

iamnewbies

ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ