Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problems parsing multiple rss feeds with PHP
Old 05-03-2010, 11:10 AM Problems parsing multiple rss feeds with PHP
Skilled Talker

Posts: 90
Trades: 0
First up, here is the code I am currently using.

PHP Code:
<?php

require( '../wp-load.php' );

// Load and parse the XML document 
$rss =  simplexml_load_file('http://feeds2.feedburner.com/bbc');
$title $rss->channel->item->title;

//Check to see if post exists
function PostNotExist($title) {
global 
$wpdb;
if(
$wpdb->get_row ("SELECT post_title FROM wp_posts WHERE post_title = '" $title "'"'ARRAY_A')) {
return 
false; } else { return true; }
}

// Loop to add each new item to Wordpress
foreach ($rss->channel->item as $item) {

if (
PostNotExist($title))  {
    
  global 
$user_ID;
$new_post = array(
    
'post_title' => $item->title,
    
'post_content' => $item->description,
    
'post_status' => 'publish',
    
'post_date' => date('Y-m-d H:i:s'),
    
'post_author' => $user_ID,
    
'post_type' => 'post',
    
'post_category' => array(0)
);
$post_id wp_insert_post($new_post);
}}

?>
Quick explanation of what I am trying to achieve. I am trying to gather multiple RSS feeds and display them on a Wordpress blog.

The first problem I have is, in the foreach loop when the post title is new, it will only get the latest new post, and not the other new ones. Probably a simple fix here, I just cannot see it.

As I said I am trying to gather multiple RSS feeds, I know I will need an array to do this but not really sure about the rest.

Any help would be much appreciated.
Thanks
__________________
Free Flash designs and tutorials at
Please login or register to view this content. Registration is FREE

Shorten your URL's with
Please login or register to view this content. Registration is FREE
xuroq is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-05-2010, 09:29 AM Re: Problems parsing multiple rss feeds with PHP
Average Talker

Posts: 22
Trades: 0
Please re-look into the code. I hope that you will fix the code by yourself. If not please post the error message if any, or what you want to see but facing difficulties.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
katierosy is offline
Reply With Quote
View Public Profile Visit katierosy's homepage!
 
Reply     « Reply to Problems parsing multiple rss feeds with PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.58697 seconds with 12 queries