Autopost to Blogger blogs with PHP

Yes, you can autopost to blogspot (blogger) blogs with php, and it’s a lot easier than you might think.

Similar to the way that plugins like wp-o-matic work for automatically posting rss feeds to Wordpress blogs, you can have a blogger blog which is automatically populated with RSS feed content, at intervals that you determine (by a cron job).

Blogger blogs allow the blogs owner to post via email, so we’re going to use PHP’s mail function to post new content, and PHP’s SimpleXML to gather the content before posting.

Firstly, we need to set up our blogger blog to accept emailed posts: We need to go to our settings page in Blogger, and click the “Settings” tab at the top. Then click the “email” button.

You’re now at the Email settings page, look for the Mail-to-Blogger Address. Here you just need to enter a password (in the box before the “@ablogger.com”) that you’ll use in your emails to post to the blogger blog.

Once you’ve chosen your password, write down the email address, as this is the email address we’ll be using in the PHP script to tell it where to post the rss feed to.

Now on to the script:

<?php

//Your Blog’s Keyword:
$keyword = “keyword”;

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

//Get the RSS Feed - In this instance, we’re using a google blogsearch feed based on our chosen keyword
$feed = simplexml_load_file(”http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&q=” .urlencode($keyword). “&ie=utf-8&num=10&output=rss”);

//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 = “accountname.password@blogger.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++;

}

?>

And that’s it.

Customise the script to suit your purposes, upload to your server, and call it via a cron job.

Tags: , ,

Twitter smartasses, The circle Jerk that is Sphinn, Social Media Wankers, Reputation Management Bullshit, and Web 2.0 crap

Those of you who have been reading this blog since before the great Database Backup Disaster of ‘08 will know that I like few things better than a good rant, so here we go; Some things that are pissing me off about the Internet Marketing / SEO sphere at the moment:

1) Twitter “power” smartasses. You know the ones, they guys who twitter in a self congratulatory style looking down from their cloud of bloated sense of self importance at the rest of the twittersphere. They usually include phrases like “seriously ppl, why do you…….?” in their tweets, and they’re ALWAYS giving out free advice to other twits or anybody else who happens to inadvertantly wander into their crosshairs, because, obviously, their opinions matter.

I’ll give you a tip - if someone’s running up over 100 tweets a day, they have far too much time on their hands, and maybe we need to question their IM/SEO “Guru” status. I’d rather be working for my clients and earning money for my family than tweeting condescending, inconsequential bullshit all day.

2) Sphinn. I mean really people, it’s just the same shit from the same people, day in, day out. There’s only so many different ways you can word the same posts about increasing your subscriber numbers, getting more twitter followers, or how to become a “social media superstar”.

Any site that only needs around 30 votes to get a story to the front page is never going to have the good content find its way to the top. Plus, if I look at the home page tomorrow, around 80% of the stories from yesterday will still be there. Not to mention that Sphinn “steals” the interaction that should be going on in blogs. I’ve had posts go hot on Sphinn that got less than five comments on my blogs, but three times that many on the Sphinn site itself. Hardly fair I would have thought.

3) Social Media Superstars. You do understand that you’re just part of a giant circle-jerk don’t you. Yeah, I’d rather be working and making money than finely crafting my social media profiles, trying to get noticed by the Superstars of social media and SEO. You’re only superstars amongst a small group of geeks and dorks (yours truly included) who probably need to get out a liitle more. Nobody outside our little circle knows or cares about your profile.

4) Reputation Management. Peeps been dissin yo rep? Just go sign up for a crapload of social media sites, create profiles, get links to them, push that nasty shit to the second page of google. Problem solved. Not that hard really, is it? Or, you could pay a Social Media Superstar a shitload of money to have them do the same thing for you. Not really that hard is it?

5) Web 2.0 Experts. Which type of web 2.0 site is that? The one where you get suckers looking for their five minutes of fame to create content for you, then you slap your own ads on it, or the speccy rounded corners mirrored images type of site? I’m yet to see anybody even satisfactorily define what web 2.0 actually is, but damnit if every web developer out there is an expert in it.

That is all.

Tags: , , ,

Embed a youtube video in your page based on a keyword from rss feed

I spent ages looking around for a simple way to automatically embed a youtube video on a page based on a keyword, and found nothing, so here’s a little script that does it for you.

I found scripts that take the thumbnail from Youtube, but I wanted to actually EMBED a video, not show a thumbnail with a link to Youtube.

In a nutshell, here’s what the script does:

1) Takes a keyword you give it

2) Generates an URL to get the Youtube RSS feed for that keyword

3) Takes the first video from that RSS feed

4) EMBEDS that video in your page, so it can be played right there, in your page.

As with most of the scripts you’ll find here, you need PHP5 installed on the server you’re going to run this script on, as it uses PHP5’s SimpleXML to parse the Youtube RSS feed.

First, the PHP to get the RSS Feed:

<?php

//Give our script a keyword to work with
$keyword=”george bush”;

//Generate a URL for our RSS feed, and download the feed using SimpleXML
$rss = simplexml_load_file(’http://gdata.youtube.com/feeds/base/videos?q=’ .urlencode($keyword). ‘&client=ytapi-youtube-search&v=2′);

//Get the part of the RSS feed which contains the number of the first video, and save it to the variable $id
$id = $rss->entry->id;

//Get rid of some stuff we don’t need
$id = str_replace(”tag:youtube.com,2008:video:”, “”, $id);

?>

And Now the part that actually embeds our video in the page (We’re actually just customising Youtube’s standard embed code here, to embed our video):

<embed src=”http://www.youtube.com/v/<?php echo $id; ?>&hl=en&fs=1&color1=0×5d1719&color2=0xcd311b” type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”320″ height=”265″></embed>

See how we’re embedding the $id variable, that’s the Youtube ID of our video.

You can download the script here

Tags: , , ,

All the free RSS feeds you could ever want

Maybe I’m a little late to the party here, but here’s someting i had no idea about.

If you’re looking for RSS feeds to augment your content, try the Microsoft Live Search Feeds…

http://search.live.com/feeds

Plonk your keyword in the box, and get back a list of RSS feeds which use those keywords.

Sweeeeet!

Tags: , ,