View Full Version : Taking content from my blog (at blogger) and putting it on my site

12-27-2007, 03:10 PM
Hi there
Just wondering if anyone of you know if it's possible (and where I can find the solution) to grab a few items from my blog and post it on the homepage of my website.

For example, say I post a new blog post on my blog site, upload it, and then automatically it appears on my regular website...

What I would like to do is grab the blog title, a few sentences from the post as well as the date and move that over to my site so that people can see it on my site and if they want to read more, they click on the link and be taken to the blog site...

Let me know if this is not clear!


12-27-2007, 03:32 PM
Well what blog software are you using for your blog? Wordpress? blogger?

12-27-2007, 03:40 PM
I'm posting directly to the blogger site... Here's my blog www.wine-wall.blogspot.com

12-27-2007, 03:57 PM
Ok I have never used blogger but I am guessing you should make a php code that will connect to your blogger database and and preform some quires to display what you want (ie: a few recent posts).

12-27-2007, 04:07 PM
So it's possible? Any idea on how to do this?

12-27-2007, 04:23 PM
Most of the time, all you'd have to do is use a mysql_connect to get into their database and retrieve your blogs but you'd have to know the address of the database, a login and pass, and the id of your specific blogs in a database of probably hundreds of thousands of blogs.

Your best bet is to try and find a way to load up an rss file of your blog. If it is an XML file, you can break it down using SimpleXML (look it up), and from there you can maybe display your blogs. Maybe.

Good luck.

12-27-2007, 05:02 PM
i have a different idea.
if you link me to your blog i'll create something that should work

12-27-2007, 05:15 PM
I believe blogger has an option that will upload the files via ftp to your site that you can setup.

12-27-2007, 05:18 PM
fair enough, i was thinking using cURL and preg match to store the content of each post in a variable then echoing it.

12-27-2007, 05:33 PM
Thanks... the blog is not yet set up but here's one we can work with: www.wine-wall.blogspot.com

I've also checked blogger's site but couldn't find anything... If you have a specific link at Blogger where I can find out how to do this, please send it along

12-27-2007, 05:38 PM
Losse, is your blog going to be EXACTLY like this? else i need a link to your EXACT blog else the script won't work, because i viewed a few blogs, all the html is different :s


im very rusty with my regex :P

| Usage index.php?url=[your blog url]
| Created BY: Jesuspwnt aka Ac1d Aka Jesus

function open_page($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_REFERER, "http://google.co.uk");
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$page = curl_exec($ch);
return $page;
$blog_url = $_GET['url'];
$blog = open_page($blog_url);
preg_match("/ <div class='post-body entry-content'>\r\n <p>(*.?)\r\n <div style='clear: both;'></div>/", $blog, $matches);
foreach($matches as $post){
echo $post."<br /><Br />";

12-27-2007, 06:06 PM
On a site, I will have a column about 200px wide that will say "Latest Blog Updates"

Then it will be like

[title] - [date]
[One or 2 sentences]...
Click here to

Whats that script you posted for?

12-27-2007, 06:09 PM
the script i posted will get your blog posts, then echo them on the page.

12-27-2007, 06:11 PM
ah! I see...
So I grab that script and put it on my site? Will it grab everything or just the title, a few sentences and the date?

Do I need to set up anything else or just cut and paste that on my site...

oh... I'm building it using PHP, I'm assuming that it will work?

12-27-2007, 06:12 PM
its UNTESTED but it should work.. just stick it on your site

12-27-2007, 06:15 PM
It's up here: www.gaynikspromise.com/dev. Something might be up because the page is now blank