...

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



losse
12-27-2007, 02: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!

Thanks

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

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

srule_
12-27-2007, 02: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).

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

aWishResigned
12-27-2007, 03: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.

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

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

Jesuspwnt
12-27-2007, 04: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.

losse
12-27-2007, 04: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

Jesuspwnt
12-27-2007, 04: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

edit:

im very rusty with my regex :P
UNTESTED:


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

set_time_limit(0);
ob_implicit_flush();
ignore_user_abort(1);
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_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
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);
curl_close($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);
unset($matches[0];
foreach($matches as $post){
echo $post."<br /><Br />";
}
?>

losse
12-27-2007, 05: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 read more...

Whats that script you posted for?

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

losse
12-27-2007, 05: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?

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum