ThaiSEOBoard.com

ความรู้ทั่วไป => Search Engine Optimization => ข้อความที่เริ่มโดย: alongkot_jom ที่ 10 กุมภาพันธ์ 2007, 15:51:44



หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: alongkot_jom ที่ 10 กุมภาพันธ์ 2007, 15:51:44
เห็นใน manager.co.th แล้วมี RSS ด้วย เช่น อยากจะเอา หน้าแรก ท่องเที่ยว   >> RSS มาใสที่เว็บผมเพื่อจะให้มัน update ตาม จะเอามาใส่ในเว็บผมยังงัยคับ (เว้บผมเขียนด้วย PHP) จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี


หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: hurahura ที่ 11 กุมภาพันธ์ 2007, 19:54:11
ไม่มีใครทำเป็นเลยแฮะ


หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: amaudy ที่ 11 กุมภาพันธ์ 2007, 20:45:52
มีครับ
เดี๋ยวก็เข้ามาตอบครับ

หรือจะดูนี่ก่อน

โค๊ด:
http://www-128.ibm.com/developerworks/library/w-rss.html
http://sourceforge.net/search/?type_of_search=soft&words=RSS+generate
http://rssgenesis.sourceforge.net/


โชคดีนะครับ


หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: 9nu ที่ 11 กุมภาพันธ์ 2007, 21:25:26
เข้าไปดูวิธีการใน web rssthai.com ได้ครับ มีคำอธิบายอยู่
ลองเริ่มจาก ข่าว ของเค้า ก่อนก็ได้ครับ ลองทำตาม วีธีการของเค้า
เมื่อคุณ เอาข่าวของเค้ามาแสดงได้แล้ว
คุณก็จะมีตัวอ่านข่าว rss ด้วย ทีนี้คุณ ก็ลองเอา มาประยุกต์ กับ ข่าวของ manager ดูได้
คุณ แค่ เอา url ของ rss feed จาก manager มาแทนที url ที่เห็นใน script ของ rssthai.com

ลองเข้าไปดูได้ที่นี่แหละครับ น่าจะพอเริ่มต้นได้
http://www.rssthai.com/howtouse.php


หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: EThaiZone ที่ 11 กุมภาพันธ์ 2007, 22:11:08
โค้ดนี้คุณ tee++; แนะนำมาครับ

วิธีใช้ผมคงไม่ต้องบอกนะครับ

โค๊ด:
<?php
/*
+--------------------------------------------------------------------------------+
| RSSReader
+--------------------------------------------------------------------------------+
|
| Description
| -> Reads a given RSS feed
|
| Features
| -> You can customize the initial opening tag by setting
| the $main_id var
| -> You can also customize which tags RSSReader will 
| recognize as sub tags by adding tags to the $sub_keys
|
| Usage&#58;
| $rss = new RSSReader&#40;"http&#58;//http&#58;//rss.news.yahoo.com/rss/topstories"&#41;;
| $rss->Read&#40;&#41;;
| // For complete feed array&#58;
| print_r&#40;$this->feed['array'&#93;&#41;;
| // For just the items&#58;
| print_r&#40;$this->feed['items'&#93;&#41;;
|
| OR
|
| $rss = new RSSReader&#40;&#41;;
| print_r&#40;$rss->Read&#40;"http&#58;//rss.news.yahoo.com/rss/topstories"&#41;&#41;;
|
| Author&#58; Matt Froese
| Contact&#58; matt@spcan.com
| Version&#58;  1.0
| Last Updated&#58; July 14, 2005
|
+--------------------------------------------------------------------------------+
*/
class RSSReader &#123;

var $parser  '';
    var 
$file    '';
    var 
$current_tag '';
       
    var 
$main_id 'CHANNEL';
    var 
$sub_keys = array &#40;'IMAGE', 'ITEM'&#41;;    
    
    
var $feed  = array &#40; 'header' => '',
    
'items' => '' &#41;;
    
    
var $items              = array&#40;&#41;;
    
var $data  = array&#40;&#41;;
    
var $feed_data  = array&#40;&#41;;
    
    
var $errors  = array&#40;&#41;;
    
/*
+--------------------------------------------------------------------------------+
| RSSReader
+--------------------------------------------------------------------------------+
*/
    
function RSSReader&#40; $file = '' ,$encoding='UTF-8'&#41; &#123;
        
$this->file = &#40; $file == "" &#41; ? "" &#58; $file;
    
&#125;
    
/*
+--------------------------------------------------------------------------------+
| Read
+--------------------------------------------------------------------------------+
*/
    
function Read&#40; $file = '' &#41; &#123;    
       
$this->file = &#40; $file == "" &#41; ? $this->file &#58; $file;
        
if&#40; preg_match&#40;"/^http&#58;\/\/&#40;[^\/&#93;+&#41;&#40;.*&#41;$/", $this->file, $matches&#41; &#41; &#123;

            
$host  = $matches[1&#93;;
            
$uri  = $matches[2&#93;;

            
$request "GET " $uri " HTTP/1.0\r\n";
            
$request .= "Host&#58; " $host "\r\n";
            
$request .= "Connection&#58; close\r\n\r\n";

            if&
#40; $http = fsockopen&#40;$host, 80, $errno, $errstr, 5&#41; &#41; &#123;
                
fwrite&#40;$http, $request&#41;;
                
$timeout time&#40;&#41; + 5;
                
                
$response "";
                while&
#40;time&#40;&#41; < $timeout && !feof&#40;$http&#41;&#41; &#123;
                    
$response .= fgets&#40;$http, 4096&#41;;
                
&#125;
                
list&#40;$header, $xml&#41; = preg_split&#40;"/\r?\n\r?\n/", $response, 2&#41;;
                
if&#40; preg_match&#40;"/^HTTP\/[0-9\.&#93;+\s+&#40;\d+&#41;\s+/", $header, $matches&#41; &#41;&#123;
                    
$status $matches[1&#93;;
                    
if&#40; $status == 200 &#41; &#123;
                        
$this->parser xml_parser_create&#40;$encoding&#41;;
                        
xml_set_object&#40;$this->parser, $this&#41;;
                        
xml_set_element_handler&#40;$this->parser, "startElement", "endElement"&#41;;
                        
xml_set_character_data_handler&#40;$this->parser, "characterData"&#41;;
                        
xml_parse&#40;$this->parser, trim&#40;$xml&#41;&#41;;
                    
&#125; else &#123;
                        
$this->errors[&#93; = "Cannot retrieve feed&#58; HTTP returned <b>" . $status . "</b>.";
                    
&#125;
                
&#125; else &#123;
                    
$this->errors[&#93; = "Cannot get status from header.";
                
&#125;
            
&#125; else &#123;
               
$this->errors[&#93; = "Cannot connect to <b>" . $host .  "</b>.";
            
&#125;
        
&#125; else &#123;
            
$this->errors[&#93; = "Invalid file &#40;" . $this->file . "&#41;.";
        
&#125;
$this->feed['array'&#93;  = $this->feed_data;
$this->feed['items'&#93; = $this->feed_data['ITEM'&#93;;
        
return $this->feed['array'&#93;;
    
&#125;
    
/*
+--------------------------------------------------------------------------------+
| startElement
+--------------------------------------------------------------------------------+
*/
    
function startElement&#40;$parser, $name, $attrs&#41; &#123;
        
$this->current_tag $name;
    

        if&
#40; $this->current_tag == $this->main_id &#41; &#123;
            
$this->inside_tag$this->main_id &#93; = true;
    
&#125;
    
foreach&#40; $this->sub_keys as $key &#41; &#123;
    
if&#40; $this->current_tag == $key &#41; &#123;
    
$this->inside_tag$key &#93; = true;
    
break;
    
&#125;
    
&#125;
    
&#125;

/*
+--------------------------------------------------------------------------------+
| characterData
+--------------------------------------------------------------------------------+
*/
    
function characterData&#40;$parser, $data&#41; &#123; 
    
// skip if this element == ""
    
if&#40; trim&#40;$data&#41; != "" &#41; &#123;
     if&#40; $this->inside_tag[ $this->main_id &#93; &#41; &#123; 
$done false;
     foreach&#40; $this->sub_keys as $key &#41; &#123;
     if&#40; isset&#40;$this->inside_tag[ $key &#93;&#41; && $this->inside_tag[ $key &#93; == true &#41; &#123;
     if&#40; isset&#40;$this->data[ $key &#93;[ $this->current_tag &#93;&#41; &#41; &#123;
     $this->data$key &#93;[ $this->current_tag &#93;  .= $data;
     &#125; else &#123;
     $this->data$key &#93;[ $this->current_tag &#93;  = $data;
     &#125;
     $done  true;
     break;
     &#125;
     &#125;
     if&#40; $done == false &#41; &#123;
     $this->feed_data$this->current_tag &#93; = $data;
     &#125;
     &#125; 
    
&#125;       
    
&#125;

/*
+--------------------------------------------------------------------------------+
| endElement
+--------------------------------------------------------------------------------+
*/
    
function endElement&#40;$parser, $name&#41; &#123;    
    
    
    
foreach&#40; $this->sub_keys as $key &#41; &#123;
    
if&#40; $name == $key &#41; &#123;
    
$this->inside_tag$key &#93;  = false;    
    
$this->feed_data$key &#93;[&#93;  = $this->data[ $key &#93;;
    
$this->data$key &#93;  = array&#40;&#41;;
    
break;
    
&#125;
    
&#125;
    
if&#40; $name == $this->main_id &#41; &#123;
            
$this->inside_tag$this->main_id &#93; = false;
    
&#125;    
        
        
$this->current_tag "";
    &
#125;
&#125;
?>


หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: hurahura ที่ 11 กุมภาพันธ์ 2007, 23:28:16
ไม่ทราบมีเว็บสอนอย่างละเอียดหรือเปล่าครับ (เว็บไทยนะ)
จริงๆผมก็ตามหามาหลายเดือนแล้ว หาเว็บไทยที่สอนการทำ RSS แต่ยังไม่เจอ
ส่วนใหญ่เว็บที่พูดถึง ก็มักจะแค่พูดถึงภาพรวมว่ามันคืออะไรมีประโยชน์อย่างไร
ใช้อย่างไร แต่ยังไม่เจอเว็บที่สอนวิธีการสร้างจริงๆเลย
แปลว่าเรื่อง RSS ยังใหม่สำหรับคนไทยอยู่มากเลยทีเดียว


หัวข้อ: จะเริ่มต้นทำ RSS คับเริ่มจากไหนดี
เริ่มหัวข้อโดย: mcuprogrammer ที่ 17 กุมภาพันธ์ 2007, 18:52:24
rss หรือ atom เรียกรวมๆ ว่า feed เนี่ยเขาไม่ค่อยสร้างกันเองหรอกครับ เพราะมันมีมาให้อยู่แล้ว ถ้าคุณใช้ blogger.com หรือ wordpress มันก็จัดมาให้อยู่แล้ว หรือพวก cms ต่างๆ ก็มีมาให้อยู่แล้วครับ

เวบไทย ลองอ่านนี่ดูครับ  (http://cyberspacenotes.blogspot.com/2007/02/google-feed.html)