Jump to content

Php Rss to Mail Post


onlinemkt

Recommended Posts

Hi everyone,

 

I have the following code used to auto post on my blog from my video site rss news:

 


<?php

//Your Blog’s Keyword:
$keyword = "something";

//How many articles do you want to grab each time?
$num = 10;

//Get the RSS Feed - In this instance, we’re using a google blogsearch feed based on our chosen keyword
$feed = simplexml_load_file("http://www.videosite.com/rss/$keyword");

//Loop through our keywords
foreach ($feed->channel->item as $item) {

if($i < $num){

//Have a bit of a rest so we’re not posting too fast to our blogger blog
sleep(10);

$title = $item ->title;
$title = str_replace("<b>", "", $title);
$subject = str_replace("</b>", "", $title);
$link = $item->link;

$description = $item ->description;
$description = str_replace("<b>", "", $description);
$body = str_replace("</b>", "", $description);

//put our secret blogger email address here:
$to = "[email protected]";

//ignore this line - the script just needs something in the “From” field.
$headers = "From: [email protected]";

//Send the email / How’d we go?
if(mail($to, $subject, $body, $headers)) {
echo $subject. " - sent<br>";
}
else
{
echo $subject. " - NOT sent<br>";

}
}
//add one to our counter
$i++;

}

?>

 

But, there´re are some problems that I need advice...

 

1) Every time I run this scipt, it keep posting reapeted videos when there´re no new videos posted on my site. Is it possible to prevent double post (based on title or date) ?

 

2) I want the script to read the video url of rss wich is given on <link> code inside rss and use the url to build a picture template of preview video images. The generated rss link is something like: http://videosite.com/movies/123456/videoname.html and the preview images of video should use some variables of that url, like: http://pc.videosite.com/f/456/1_123456.jpg and second image: http://pc.videosite.com/f/456/2_123456.jpg, and third http://pc.videosite.com/f/456/3_123456.jpg, and so on... the variable change is on the number before underline and the three numbers before ".jpg" wich is used on the url as an id.

 

Is it possible to make this ? ? ? I tried searching everywhere but no success.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/159317-php-rss-to-mail-post/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.