KONY 2012 - one thing we can all agree on - read more

Bahrain

Get wordpress posts in flash …

got flooded recently with emails requesting a tutorial on how to get wordpress posts into flash , now i dont have enough time to make a tut , but i will go through it in here quickly so pay attention .

Important links :
XML-RPC on WordPress
XML-RPC home
XML-RPC tutorial press

———————————————-
Now as far as i remember i downloaded the movable type class from here http://www.dentedreality.com.au/bloggerapi/

download the MTC ( movable type class ) and extract them in your folder on your webspace ( should support php) .

Now open up a new php document call it what ever you want , i called it test.php copy & paste the following code :


< ?php
include_once("class.mtclient.php");
$username = "USERNAME"; //Blog user name
$password = "PASS"; // Blog Pass
$host = "zainal.wordpress.com"; //change this to your wordpress site
$path = "/xmlrpc.php";//"/path to xmlrpc , keep it as it is , sometimes it needs
// the full path e.g www.abcd.com/blog/xmlrpc.php
// create a new blog
$blog = new mtclient($username, $password, $host, $path);
//get last 6 posts ...
$myBlogs = $blog->getRecentPosts($username , 6);
//cant remember why i kept the counter ....
//OH YA the counter will be used to plot user_data e.g user_data1 , user_data2 , notice the &
// mark below its what flash will read and split data based on " | " ....
$counter = 1;
// loop through the MultiD array
for ( $row = 0; $row < 6; $row++ )
{
//At this end you can always Produce XML doc , or as in my case i added "|"
// so i can split Data in flash later on ...
print "&user_data$counter=".$myBlogs[$row][title].'|'.$myBlogs[$row][link];
$counter++;
}
?>

now you can get more than title and link here is an explanation :

/* usage:

requires the following files to be in the same directory:
class.bloggerclient.php
xmlrpc.php

re-implements the following methods with metaWeblog
which returns strings “description”, “link”, and “title”
instead of a single “content” string.

getRecentPosts
getPost
newPost
editPost

also adds the special movabletype methods
which allow category assignment and retrieval
and for listing of supported methods

getCategoryList
getPostCategories
setPostCategories
supportedMethods

example:

include_once(“class.mtclient.php”);

$username = “myusername”;
$password = “mypassword”;
$host = “www.myhost.com”;
$path = “/path/to/mt-xmlrpc.cgi”;

$blog = new mtclient($username, $password, $host, $path);
$myBlogs = $blog->getUsersBlogs();
*/

flash code :

var sender = new LoadVars();
var receiver = new LoadVars();
high= 22;
u = 0;
url = [];
receiver.onLoad = function(ok){
if(ok) {
loader.unloadMovie();
for (var i = 1; i < = 6; ++i)
{
receiver["dataPacket" +i] = receiver["user_data" + i].split("|");
var Ntitle = receiver["dataPacket" + i][0];
url[i] = receiver["dataPacket" + i][1];
trace ("data " + Ntitle);
trace ("data " + url[i]);
trace('attaching');
_root.attachMovie("box", "box" + i, _root.getNextHighestDepth());
_root["box"+i].btn.ID = i;
_root["box"+i].pTitle.text = Ntitle;
_root["box"+i].btn.onPress = function() {
getURL(url[this.ID],_blank);
}
_root["box"+i].btn.onRollOver = function() {
trace('get some');
}
_root["box"+i]._y = 65 +(high * u);
trace('hight ' + (high * u));
_root["box"+i]._x = 0;
u++;
delete receiver["user_data" + i];
}
}
}
sender.sendAndLoad("http://localhost/movabletypeClass/test.php", receiver, "post");

Like i said earlier , you can always produce XML doc from the test.php and read that in flash , there are many ways you can read external files , it all depends on YOU !
Flash & php source files can be downloaded from here ...@ ZAINALS

Related posts:

  1. Getting WordPress posts into Flash!
  2. Reversing Flash TimeLine using setInterval
  3. ActionScript Idle Timer , Can be used as a screen Saver.
  4. Get X & Y resolution using flash …
  5. Depth Control in Flash .

17 Responses to “Get wordpress posts in flash …”

  1. On April 25, 2007 at 7:56 am Charles responded with... #

    Hi Zainal, this looks perfect for what I am up to at the moment. As a start I decided to implement your flash movie – at arbu.co.uk/wordpress.html but I keep getting “undefined” in each of the entries. This is better than the blankness it began with, but I am at a loss. Can you help me get the titles in the buttons? What could be doing this? Thanks in advance.

  2. On April 25, 2007 at 8:41 am Mohammed Zainal responded with... #

    Hi charles ,
    i believe its the PHP file , can you test the php file alone without the flash and see if it outputs the posts from wordpress …?

    if it doesn’t work then get me your icq , msn or yahoo IM and we’ll sort it out .

  3. On April 26, 2007 at 2:58 am Charles responded with... #

    Thanks for the reply. On arbu.co.uk/test.php I get the error message: “XML-RPC server accepts POST requests only.” I googled this and have the patched version of xmlrpc.php. What do you reckon? Best Charles

  4. On April 26, 2007 at 3:12 am Mohammed Zainal responded with... #

    i reckon us exchanging IM’s !

  5. On April 26, 2007 at 6:27 am Charles responded with... #

    Aye – AIM: CharlesSelwyn. Cheers

  6. On April 26, 2007 at 9:13 am Mohammed Zainal responded with... #

    any chance that you are using yahoo , msn or icq ?

  7. On April 27, 2007 at 3:40 am Charles responded with... #

    yahoo: charlesselwyn ;-)

  8. On April 27, 2007 at 4:52 am Charles responded with... #

    Just a quick note to say thanks — couldn’t have done it without you and what a superb bit o’ coding!

  9. On April 27, 2007 at 8:50 am Mohammed Zainal responded with... #

    cheers matey , thats so kind of you !!!

    stay in touch , if ya need any help drop me an email …
    btw , i love your website !!

  10. On October 12, 2008 at 4:28 pm ahimsauzi responded with... #

    Great code Zainal! I am having similar issue as Chris did. Any chance you can post a fix?

    Thanks,

    Ahimsa

  11. On March 24, 2009 at 1:28 pm Erik responded with... #

    Hey Zainal. First I just want to say thanks for posting this, this is exactly the tool I am looking for. For some reason when I publish the page I just get the “Loading Posts” animation and nothing happens. If I view the browsers activity this it what it says:

    http://localhost/test/test.php internal server error

    any idea why this would be happening? Any suggestions would be appreciated. Thanks a lot.

    -Erik

  12. On March 24, 2009 at 1:43 pm Mohammed Zainal responded with... #

    hi Erik, did you download the files from http://www.zainals.com/loads/blog/xperments/flash-Wordpress.rar ?

    i posted this about 2 years ago matey, i will try to squeeze my brains, but before that download my files and make sure you have setup PHP properly … i use WAMP for my experiments .

    BTW if you use AS3 it will be easier to grab the xml from the feeds :-)

  13. On March 28, 2009 at 11:32 pm Reuben responded with... #

    I’ve actually just finished developing an open source AS3 library that can be used for easily connecting WordPress XML-RPC with flash.

    You can get documentation and source from here:
    http://blog.absentdesign.com/?page_id=22

    Cheers,

    Reuben

  14. On March 29, 2009 at 1:30 am Mohammed Zainal responded with... #

    thanks for sharing the library Reuben.

  15. On April 1, 2009 at 7:02 am David responded with... #

    Hi Zainal,
    Your code seams to be great for what I’m looking for. But
    I have exactly thensame problem than Charles. Perhaps you can give me some tips.
    Kind Regards.
    David

  16. On April 11, 2009 at 11:21 am Will responded with... #

    I’ve done this in flex with the google api for as3 xml-rpc http://imedia-ventures.com/accessing-wordpress-content-from-other-software-flash-etc/

  17. On August 6, 2009 at 4:24 pm rob responded with... #

    great bit of code! I was wondering if there is an easy way to grab meta data such as images associated with the post.

    Cheers!

Add your response