• پایان فعالیت بخشهای انجمن: امکان ایجاد موضوع یا نوشته جدید برای عموم کاربران غیرفعال شده است

[ آموزش ] نحوه نمایش آخرین مطالب فید یک سایت در سایتی دیگر

MihanV

مدیر بازنشسته
تاریخ عضویت
29 جولای 2010
نوشته‌ها
11,979
لایک‌ها
30,429
محل سکونت
کرج
عنوان معلومه آموزش راجع به چی هست :D

اگر سایت وردپرسی دارید این مطلب رو ببینید : نمایش آخرین مطالب یک سایت در سایتی دیگر در وردپرس


اول یک فایل بسازید با نام : RssAgent.php
بعد کدهای زیر رو توی این فایل قرار بدید :
PHP:
       <?php
    include("RssAgent.php");
    $RSS = new RssAgent( "http://mihanv.com/feed/" );
    for( $i = 0; $i < 5 ; $i++ )
    {
    echo '<a class="_link" href="' . $RSS->link[$i] . '" target="_blank"><img src="wp-content/themes/novin/images/tik.png" border="0" alt="' . $RSS->title[$i] . '" />' . $RSS->title[$i] . '</a> <div class="clear5"></div>';

    echo "";
    }
    ?>



<?php
    /*
    *
    * Free Library - RssAgent
    *
    * Name: RssAgent
    * Description: RSS Reader (RSS v2.0, http://cyber.law.harvard.edu/rss/rss.html)
    * -> Reading an RSS feed from a website
    * Author: Damjan Krstevski - SkyDriver
    * License: Freeware, you can use, copy, edit, redistribute and etc...
    *
    */
    /* ****************************** Start Class ****************************** */
    class RssAgent {
    /* *** Declaring variables *** */
    var $title = array(),
    $link = array(),
    $description = array(),
    $category = array(),
    $guid = array(),
    $pubDate = array();
    /* *** End of Declaring variables *** */
    /* *** Construct *** */
    function __construct( $urlFeed = NULL ) {
    $content = @file_get_contents( $urlFeed ); // Get the content from URL
    $x = new SimpleXmlElement( $content ); // Parse XML using SimpleXmlElement Class
    foreach( $x->channel->item as $entry ) // Fill the arrays with the rss feed
    {
    array_push( $this->title, $entry->title ); // Append title
    array_push( $this->link, $entry->link ); // Append link
    array_push( $this->description, strip_tags( $entry->description ) ); // Strip HTML tags and append description
    array_push( $this->category, $entry->category ); // // Append category
    array_push( $this->guid, $entry->guid ); // // Append guid
    array_push( $this->pubDate, $entry->pubDate ); // Append pubDate
    }
    }
    /* *** End of Construct *** */
    }
    /* ****************************** End Class ****************************** */
    ?>

بعد به جای http:// mihanv .com/feed ادرس فید مورد نظر رو بزارید

بعد جایی که میخواید آخرین مطالب رو نمایش بدید این کد رو بزارید :

PHP:
<?php
    include("RssAgent.php");
    $RSS = new RssAgent( "http://mihanv.com/feed/" );
    for( $i = 0; $i < 5 ; $i++ )
    {
    echo '<a class="_link" href="' . $RSS->link[$i] . '" target="_blank"><img src="theme/site/images/tik.png" border="0" alt="' . $RSS->title[$i] . '" />' . $RSS->title[$i] . '</a> <div class="clear5"></div>';

    echo "";
    }
    ?>

بعد به جای http:// mihanv .com/feed ادرس فید مورد نظر رو بزارید
موفق باشید :)
 
Last edited:

sina1415

Registered User
تاریخ عضویت
3 اکتبر 2010
نوشته‌ها
1,019
لایک‌ها
260
عنوان معلومه آموزش راجع به چی هست :D

اول یک فایل بسازید با نام : RssAgent.php
بعد کدهای زیر رو توی این فایل قرار بدید :
PHP:
       <?php
    include("RssAgent.php");
    $RSS = new RssAgent( "http://mihanv.com/feed/" );
    for( $i = 0; $i < 5 ; $i++ )
    {
    echo '<a class="_link" href="' . $RSS->link[$i] . '" target="_blank"><img src="wp-content/themes/novin/images/tik.png" border="0" alt="' . $RSS->title[$i] . '" />' . $RSS->title[$i] . '</a> <div class="clear5"></div>';

    echo "";
    }
    ?>



 <?php
    /*
    *
    * Free Library - RssAgent
    *
    * Name: RssAgent
    * Description: RSS Reader (RSS v2.0, http://cyber.law.harvard.edu/rss/rss.html)
    * -> Reading an RSS feed from a website
    * Author: Damjan Krstevski - SkyDriver
    * License: Freeware, you can use, copy, edit, redistribute and etc...
    *
    */
    /* ****************************** Start Class ****************************** */
    class RssAgent {
    /* *** Declaring variables *** */
    var $title = array(),
    $link = array(),
    $description = array(),
    $category = array(),
    $guid = array(),
    $pubDate = array();
    /* *** End of Declaring variables *** */
    /* *** Construct *** */
    function __construct( $urlFeed = NULL ) {
    $content = @file_get_contents( $urlFeed ); // Get the content from URL
    $x = new SimpleXmlElement( $content ); // Parse XML using SimpleXmlElement Class
    foreach( $x->channel->item as $entry ) // Fill the arrays with the rss feed
    {
    array_push( $this->title, $entry->title ); // Append title
    array_push( $this->link, $entry->link ); // Append link
    array_push( $this->description, strip_tags( $entry->description ) ); // Strip HTML tags and append description
    array_push( $this->category, $entry->category ); // // Append category
    array_push( $this->guid, $entry->guid ); // // Append guid
    array_push( $this->pubDate, $entry->pubDate ); // Append pubDate
    }
    }
    /* *** End of Construct *** */
    }
    /* ****************************** End Class ****************************** */
    ?>

بعد به جای http:// mihanv .com/feed ادرس فید مورد نظر رو بزارید

بعد جایی که میخواید آخرین مطالب رو نمایش بدید این کد رو بزارید :

PHP:
<?php
    include("RssAgent.php");
    $RSS = new RssAgent( "http://mihanv.com/feed/" );
    for( $i = 0; $i < 5 ; $i++ )
    {
    echo '<a class="_link" href="' . $RSS->link[$i] . '" target="_blank"><img src="theme/site/images/tik.png" border="0" alt="' . $RSS->title[$i] . '" />' . $RSS->title[$i] . '</a> <div class="clear5"></div>';

    echo "";
    }
    ?>

بعد به جای http:// mihanv .com/feed ادرس فید مورد نظر رو بزارید
موفق باشید :)


سلام


RssAgent.php رو ساختم .. اینم ادرس جایی که آپ کردم .. اصلا چیزی نمیاد

http://iran30t.com/bank/wp-includes/RssAgent.php

بعد از ساختن این باید کجا آپش کنیم .. بعد اون کد چه جوری به این وصل میشه؟
 

MihanV

مدیر بازنشسته
تاریخ عضویت
29 جولای 2010
نوشته‌ها
11,979
لایک‌ها
30,429
محل سکونت
کرج
بالا