ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.com< กดยุบ (ห้องยกเลิกการใช้งาน)TWGอยากถามเกี่ยวกับ rss ครับ
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: อยากถามเกี่ยวกับ rss ครับ  (อ่าน 4468 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
youcanberich
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 124
ออฟไลน์ ออฟไลน์

กระทู้: 2,791



ดูรายละเอียด
« เมื่อ: 03 ธันวาคม 2006, 01:49:37 »

ผมอยากจะให้ 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>");
?>
บันทึกการเข้า

abac401
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 37
ออฟไลน์ ออฟไลน์

กระทู้: 2,683



ดูรายละเอียด
« ตอบ #1 เมื่อ: 03 ธันวาคม 2006, 01:56:26 »

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

พลังน้ำใจ: 2
ออฟไลน์ ออฟไลน์

กระทู้: 203



ดูรายละเอียด
« ตอบ #2 เมื่อ: 03 ธันวาคม 2006, 02:02:59 »

แก้ที่บรรทัด 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
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 28
ออฟไลน์ ออฟไลน์

กระทู้: 9,611



ดูรายละเอียด
« ตอบ #3 เมื่อ: 03 ธันวาคม 2006, 07:17:56 »

โค๊ด:
$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
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 124
ออฟไลน์ ออฟไลน์

กระทู้: 2,791



ดูรายละเอียด
« ตอบ #4 เมื่อ: 03 ธันวาคม 2006, 13:11:55 »

ok ครับ เดี๋ยวลองไปแก้ดู
บันทึกการเข้า

youcanberich
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 124
ออฟไลน์ ออฟไลน์

กระทู้: 2,791



ดูรายละเอียด
« ตอบ #5 เมื่อ: 03 ธันวาคม 2006, 13:18:09 »

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

ผมว่าน่าจะได้นะครับ แต่หัวข้อข่าวควรจะไม่ซำ้กับของเก่าอะครับ เช่น ทำไป 5 หัวข้อ
พอ อัพใหม่เปลี่ยนแค่หัวข้อเดียวที่เหลือเหมือนเดิม ยังงี้ไม่รู้ครับ ที่ผมทำก็ เปลี่ยนทั้งหมดเลย
บันทึกการเข้า

iamnewbies
เจ้าพ่อบอร์ดเสียว
*

พลังน้ำใจ: 28
ออฟไลน์ ออฟไลน์

กระทู้: 9,611



ดูรายละเอียด
« ตอบ #6 เมื่อ: 03 ธันวาคม 2006, 13:19:29 »

ลองดูกระทู้นี้ครับ

http://www.thaiseoboard.com/viewtopic.php?p=39828#39828
บันทึกการเข้า

ุอิอิ  พลุบๆโพล่ๆ  เข้าๆออกๆ เสียวๆ
หน้า: [1]   ขึ้นบน
พิมพ์