rss to email script?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oliver Spiesshofer

    rss to email script?

    Hi,

    is there a script out there that can send RSS feeds to a given email
    account? I have search the usual suspects (google, SF, FM, hotscripts) but
    could not find anything

    thanks

    Oliver

  • NC

    #2
    Re: rss to email script?

    Oliver Spiesshofer wrote:[color=blue]
    >
    > is there a script out there that can send RSS feeds to a given email
    > account?[/color]

    It's a two-line affair, really:

    $rss_feed = file_get_conten ts('http://example1.com/feed.rss');
    mail('user@exam ple2.com', 'RSS Feed from Example1.com', $rss_feed,
    'Content-Type: application/rss+xml');

    Cheers,
    NC

    Comment

    • Oliver Spiesshofer

      #3
      Re: rss to email script?

      "NC" <nc@iname.com > wrote in news:1109098736 .662898.47610
      @c13g2000cwb.go oglegroups.com:
      [color=blue]
      > Oliver Spiesshofer wrote:[color=green]
      >>
      >> is there a script out there that can send RSS feeds to a given email
      >> account?[/color]
      >
      > It's a two-line affair, really:
      >
      > $rss_feed = file_get_conten ts('http://example1.com/feed.rss');
      > mail('user@exam ple2.com', 'RSS Feed from Example1.com', $rss_feed,
      > 'Content-Type: application/rss+xml');[/color]

      yes but not exactly what I want.
      I want each item of the rss sent as a seperate email with the proper $from
      $subject etc fields filled in so I can mark single items as read. Also, it
      should not send anything twice, and check for new items in the rss feed at
      a given interval.

      Oliver

      Comment

      • NC

        #4
        Re: rss to email script?

        Oliver Spiesshofer wrote:[color=blue]
        >[color=green][color=darkred]
        > > > is there a script out there that can send RSS feeds to
        > > > a given email account?[/color]
        > >
        > > It's a two-line affair, really:
        > >
        > > $rss_feed = file_get_conten ts('http://example1.com/feed.rss');
        > > mail('user@exam ple2.com', 'RSS Feed from Example1.com', $rss_feed,
        > > 'Content-Type: application/rss+xml');[/color]
        >
        > yes but not exactly what I want.
        > I want each item of the rss sent as a seperate email with
        > the proper $from $subject etc fields filled in so I can mark
        > single items as read. Also, it should not send anything twice,
        > and check for new items in the rss feed at a given interval.[/color]

        Ah, now we are talking specifications. .. First of all, "check
        for new items in the rss feed at a given interval" cannot be
        implemented in PHP; you'll have to use OS-level scheduling
        facilities for that.

        Given your preference for itemization, I don't think you'll be
        able to find anything that will fit you out of the box. This,
        however, should get you started:

        $content = file_get_conten ts('http://example1.com/feed.rss');
        $p = xml_parser_crea te();
        xml_parse_into_ struct($p, $content, $vals, $index);
        xml_parser_free ($p);
        unset($content) ;
        foreach ($index['LINK'] as $key => $link_id) {
        $title_id = $index['TITLE'][$key];
        $description_id = $index['DESCRIPTION'][$key];
        $title = $vals[$title_id]['value'];
        $link = $vals[$link_id]['value'];
        $description = $vals[$description_id]['value'];
        $subject = 'Example1.com: ' . $title;
        $message = $title . "\r\n" . $link . "\r\n\r\n" .
        wordwrap($descr iption, 72, "\r\n");
        mail('user@exam ple2.com', $subject, $message);
        }

        The only functionality missing from your request is "it should
        not send anything twice". You can implement it by creating
        a log file or a database where you will store URLs of pages
        whose descriptions have already been sent. Let's say you
        implemented these two functions:

        boolean link_logged(str ing $link)
        Returns true if $link is already in the database or false
        otherwise.

        void log_link(string $link)
        Adds a new record to the log.

        Then your code can morph into something like this:

        $content = file_get_conten ts('http://example1.com/feed.rss');
        $p = xml_parser_crea te();
        xml_parse_into_ struct($p, $content, $vals, $index);
        xml_parser_free ($p);
        unset($content) ;
        foreach ($index['LINK'] as $key => $link_id) {
        $title_id = $index['TITLE'][$key];
        $description_id = $index['DESCRIPTION'][$key];
        $title = $vals[$title_id]['value'];
        $link = $vals[$link_id]['value'];
        $description = $vals[$description_id]['value'];
        if (!link_logged($ link)) {
        $subject = 'Example1.com: ' . $title;
        $message = $title . "\r\n" . $link . "\r\n\r\n" .
        wordwrap($descr iption, 72, "\r\n");
        mail('user@exam ple2.com', $subject, $message);
        log_link($link) ;
        }
        }

        Proper "From:" heading is still missing, but it wouldn't be
        too hard to add...

        Cheers,
        NC

        Comment

        • Oliver Spiesshofer

          #5
          Re: rss to email script?

          thanks a lot for your help.
          Finally I took a RSS parser (DOMIT) and made a database, cronjob etc.

          You can take a look at it at

          BitiBet is your trusted guide to crypto betting sites. Compare Bitcoin sportsbooks, ETH online casinos casinos & cricket betting. Fast, secure, anonymous.


          You have t oregister on the site however in order to verify the email
          address...

          Oliver

          Comment

          Working...