Forum Moderators: coopster

Message Too Old, No Replies

RSS to Mail Php Post

A script to post content from my video site to my blog.

         

onlinemkt

9:02 pm on May 22, 2009 (gmt 0)

10+ Year Member



Hi everyone,

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

[b]

<?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 = "mymail.pass@blog.com";

//ignore this line - the script just needs something in the “From” field.
$headers = "From: mail@whatever.com";

//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++;

}

?>
[/b]

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.

coopster

2:10 pm on May 26, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, onlinemkt.

Is it possible to prevent double post (based on title or date) ?

Sure. Just compare the timestamp/date of the video with the last time you ran your process and ignore/skip any that have already been processed.

onlinemkt

2:16 pm on May 26, 2009 (gmt 0)

10+ Year Member



Thanks for response but can´t realize how to that on that code.