Coder Social home page Coder Social logo

befeedparser's Introduction

BEFeedParser - Wordpress JSON Processor for iOS

Loosely based off the idea behind MWFeedParser https://github.com/mwaterfall/MWFeedParser

Features

  • Easily download Wordpress articles to represent in your application.
  • Post comments from within your application. (Only tested on default Wordpress comments)
  • iOS and Mac Capable (Uses AFNetworking which is compatible with both platforms)

Requirements for WebSite

  • Wordpress
  • JSON API for Wordpress

Required Libraries

Usage

  1. Set your object as a BEFeedParserDelegate

  2. Implement the following delegate methods:

    // Called on delegate giving it an array of article objects
    -(void)articlesDownloaded:(NSArray*)articles;
    // Called on delegate giving it a single article object
    -(void)singleArticleDownloaded:(id)article;
    // Called on delegate giving it an array of comment objects
    -(void)commentsDownloaded:(NSArray*)comments;
    // Called on failure or success of posting comments
    -(void)commentFailedToPost;
    -(void)commentPostedSuccessfully;

  3. Create and allocate a BEFeedParser object:

    BEFeedParser *parser = [[BEFeedParser alloc] init];

  4. Set the delegate:

    parser.delegate = self;

  5. Call one of the following with a URL to the JSON API (http://wordpress.com/?json=1)

    // Downloads articles, then calls [delegate articlesDownloaded:] [parser downloadArticlesWithURL:url]; // Downloads single article, then calls [delegate singleArticleDownloaded:] [parser downloadSingleArticleWithURL:url]; // Downloads comments, then calls [delegate commentsDownloaded:] [parser downloadCommentsWithURL:url];

  • If you experience weirdness, check what is returned by opening a web browser to: yoursite.com/?json=1

TIP: In the apps I use this in, I used the following string appended to the website URL + a page number so more articles can be downloaded later.

"?json=1&include=title,author,status,thumbnail,url,content,comment_count&count=10&page="

Send comments

  1. Create a BEFeedParser object
  2. Call the function, passing the URL of the article to comment on
    [feedParser postCommentWithName:@"Name" email:@"Email" message:@"A Message" url:urlOfPost postID:idOfThePost

Data Structures

BEArticle - object representing a Wordpress Article

Data:

  • NSString *article_id;
  • NSString *title; // This may contain HTML.
  • NSString *content; // This contains raw HTML from the article.
  • NSString *url;
  • NSString *thumbnail; // This contains the link to the Featured Image.
  • NSString *author;
  • NSString *commentCount;

BEComment - object representing a Wordpress Comment

Data:

  • NSString *comment_Id;
  • NSString *author;
  • NSString *content; // This contains raw HTML from the comment.
  • HTML is left in case you want the styling as it appears on the website. GoogleToolBox has functions that will strip HTML from the string.

Closing

At this time, I have nothing more I would like to add to this library, however it is open to anyone who wants to add and expand on it.

befeedparser's People

Contributors

truehybridx avatar

Watchers

 avatar  avatar

Forkers

justvanbloom

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.