Git Product home page Git Product logo

as3-wordpress-parser's Introduction

AS3-wordpress-parser

Our wordpress parser classes are just some abstarct codes to control the pure wordpress data such as your posts, comments, etc... and treat these data in any way that you like inside your AS3 projects; for example you can use it to create a Wordpress mobile application for your client or creating a wprdpress flash plugin or anything else related to wordpress... so you need something easy and handy to provide you the needed information :)

before using this class, you need to install http://wordpress.org/extend/plugins/json-api/ plugin on your wordpress.

Preview:

http://myappsnippet.com/?p=27

Usage:

import com.doitflash.remote.wp.WordPressParser;
import com.doitflash.remote.wp.Sql;
import com.doitflash.events.WpEvent;

var _wp:WordPressParser = new WordPressParser("http://localhost/wordpress/", 2); // arguments: address of my WP blog, load 2 posts on each request

_wp.addEventListener(WpEvent.RECENT_POSTS, onRecentPosts);
_wp.addEventListener(WpEvent.POST_CONTENT, onPostContent);
_wp.addEventListener(WpEvent.SEARCH_RESULT, onSearchResult);
_wp.addEventListener(WpEvent.SUBMIT_COMMENT, onCommentResult);

_wp.getRecentPosts(); // start loading recent posts

// after loading some recent posts, we know the posts id, so we can call one of them to get its information
//_wp.getPost(1); // load the post id: 1 content information

_wp.search("title");

// submit a new comment to the post id: 1
//_wp.submitComment("Ali", "[email protected]", "my message!", 1);


// after we have called _wp.getRecentPosts() and our recent posts are loaded, this function will be triggered
private function onRecentPosts(e:WpEvent):void
{
	trace(_wp.posts.totalPosts); // get the total posts number
	trace(_wp.posts.loadedPosts.length); // get the loaded posts number
	
	// e.param.length is 2 right now, as we have set to load 2 recent posts each time we call _wp.getRecentPosts(), when we were initializing our class
	for (var i:int = 0; i < e.param.length; i++) 
	{
		var post:Object = e.param[i];
		
		// e.param[i] includes all of the posts information such as id, type, slug, url and etc...
		trace("post.id = " + post.id);
	}
}

// after we have called _wp.getPost(1) and our specified post content is loaded, this function will be triggered
private function onPostContent(e:WpEvent):void
{
	for (var name:String in e.param) // e.param includes the specified post content information
	{
		trace(name)
	}
}

// after we have called _wp.search("title") and our search result is ready, this function will be triggered
private function onSearchResult(e:WpEvent):void
{
	trace(_wp.searchPosts.totalPosts); // get the total posts number which contain the word "title" 
	trace(_wp.searchPosts.loadedPosts.length); // get the loaded posts number which contain the word "title"
	
	// e.param.length is 2 right now, as we have set 2 as the value of the second argument of our class when we were initializing it
	// so it gives us 2 posts which contain the word "title"; so if we like to see more results, we call _wp.search(null), to search the last word we have searched once again and give us the rest of the results
	for (var i:int = 0; i < e.param.length; i++) 
	{
		var post:Object = e.param[i];
		trace("post.id = " + post.id)
	}
}

// after we have called _wp.submitComment("Ali", "[email protected]", "my message!", 1), this function will be triggered
private function onCommentResult(e:WpEvent):void
{
	trace(e.param.status); // we get our comment status, whether it is waiting for moderation or couldn't be sent or is ok!
}

as3-wordpress-parser's People

Contributors

myflashlab avatar ponteha avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.