WordPress.org

Ready to get started?Download WordPress

Forums

Create Custom XML Feed for flash (11 posts)

  1. LiFTED
    Member
    Posted 6 years ago #

    Hi there, I posted a request a while ago in the feature requests section and managed to get response to this issue. the only trouble is that I am still as of yet unable to render a custom xml feed for flash modules inserted into our wordpress blog.

    What I am trying to do is have a custom piece of PHP which dynamically creates a piece of xml for a flash module to read.
    Please see my previous post @ http://wordpress.org/support/topic/179291?replies=5#post-771099

    I have implemented a php file exactly as scribblerguy recommended, but it seems that Flash cannot recognize this data as xml simply because the document's content type seems to be set to text/html.

    Can anyone offer some insight????

  2. LiFTED
    Member
    Posted 6 years ago #

    to make it clearer to everyone I have pasted some urls for you all to take a look at. the first is the custom piece of php I wrote to create this custom feed.

    quotes.php

    this next link is to a wordpress rss feed file which I have customized to output the same data structure as the quotes.php file.
    feed=rss

    both of these documents have content type text/html and both appear to be pretty much the same when viewed in the browser or when viewing the page source. Yet strangely enough the Flash is unable to read the data produced by the quotes.php file and it CAN read the data produced by the feed-rss file??

    Can anyone help!?

  3. LiFTED
    Member
    Posted 6 years ago #

    To make things as simple as possible for you all I have pasted in the code for the files associated with this issue.

    QUOTES.PHP

    <?php require('wp-blog-header.php'); ?>
    <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
    
    <xml>
    	<quotes>
    
    	<?php
    
    	$args = array(
    		'numberposts' => 5,
    		'post_status' => null,
    		'post_parent' => null, // any parent
    		);
    
     		$posts = get_posts($args); 
    
    		?>
    
    		<?php if( $posts ) : ?>
    
    			<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    
    				<?php
    					$author = get_post_meta($post->ID, 'postAuthor', true);
    					?>
    
    					<quote>
    
    						<Id><?php the_ID(); ?></Id>
    						<Author><?php if($author == "" || $author == null){ the_author(); }else{ echo $author; } ?></Author>
    						<Text><?php the_excerpt(); ?></Text>
    						<Link><?php the_permalink();  ?></Link>
    
    					</quote>
    
    					<?php endforeach; ?>
    
    				<?php endif; ?>
    
    			</quotes>
    
    </xml>
  4. LiFTED
    Member
    Posted 6 years ago #

    And this is the feed-rss file I have hi-jacked:

    <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
    
    <xml>
    	<quotes>
    
    <?php while (have_posts()) : the_post(); ?>
    
    		<?php
    			$author = get_post_meta($post->ID, 'postAuthor', true);
    			?>
    
    			<quote>
    
    				<Id><?php the_ID(); ?></Id>
    				<Author><?php if($author == "" || $author == null){ the_author(); }else{ echo $author; } ?></Author>
    				<Text><?php the_excerpt(); ?></Text>
    				<Link><?php the_permalink();  ?></Link>
    
    			</quote>
    
    <?php endwhile; ?>
    
    			</quotes>
    
    </xml>
  5. adrock31
    Member
    Posted 5 years ago #

    @lifted,

    Did you ever find a solution to this? I'm considering doing something similar, and looking for advice.

    Thanks,

    jason

  6. Brian Kaupa
    Member
    Posted 5 years ago #

    Have you tried setting the content type in the page header?

    header('Content-Type: text/xml');

  7. MuschPusch
    Member
    Posted 5 years ago #

    Hi folks,

    i think it would be nicer if you write the xml output to a file.

    Define an action: http://codex.wordpress.org/Plugin_API/Action_Reference

    And write it to a file...

    regards Volkan

  8. simophat
    Member
    Posted 5 years ago #

    Add this to your .htaccess file in your http://dev.liftdigital.ca/lift/ directory

    RewriteEngine on

    RewriteRule ^quotes.xml$ quotes.php

    this changes your filename and you can access it by flash

    please let me know how you go

    simon

  9. simophat
    Member
    Posted 5 years ago #

    By the way,
    i am trying to setup flash using wordpress as a cms! how did you go....? i will probably use the RSS feeds option instead of custom php script because i dont know php that well..

    What has been your experience in this area?

    cheers

    Simon

  10. absent
    Member
    Posted 5 years ago #

    @ simophat - slightly off topic but I have developed an open source AS3 library that you can use if you want to use wordpress as a CMS for a flash (using the WordPress XML-RPC interface)
    http://blog.absentdesign.com/as3-library-for-the-wordpress-api/

  11. Kinchan
    Member
    Posted 5 years ago #

    Hi. I created a couple of custom theme templates to make this happen. Works fine for me and allows you to upload images via wordpress' native media upload features...no need for plugins etc. I hope someone can find a use for this so have put up some notes here. The example is for xml creation with the free autoviewer flash gallery, but would allow for tweaking to suit your xml needs.

    Leave a comment if it doesn't make sense and I'll adjust accordingly!

    http://www.genki.co.nz/cramp/?p=7

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Topic