SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Creating native apps
  with WordPress
             Marko Heijnen
 January 14, 2012 at WordCamp Norway
Marko Heijnen
Freelance developer
Mobile / WordPress


http://markoheijnen.com
info@markoheijnen.com
@markoheijnen
History
2006: Started with WordPress
2009: Started with iOS development
2010: First patch to WordPress ( 3.0 )
2011: Combined iOS development with WordPress
2012: First WordCamp presentation
Lets talk mobile
Mobile is the growing
There is a change you
 get involved with it
Native app vs
Web app/site
Native vs mobile
Build a native app when:
   People are going to use it quite often ( daily basis )
   Features that aren’t possible for web ( yet )
   A lot of users request for it ( 10.000 > )
   Customers really want an app
We need
a native app
What does it mean for you
You need to communicate with another developer
Need to build an API that the developer can use
So you need to understand what a mobile developer wants
Need to build additional fields in WordPress for information
that the mobile app can use
The API
API of the app
WordPress for iOS uses XML-RPC
WordPress support it by default
Supports: Blogger API, metaWeblog API, and the Movable
Type API
Where can you find it
/xmlrpc.php
   handles the request
/wp-includes/class-wp-xmlrpc.server.php
   Registers all the default methods
Methods for testing
/**                                                  /**
  * Test XMLRPC API by saying, "Hello!" to client.     * Test XMLRPC API by adding two numbers for client.
  *                                                    *
  * @since 1.5.0                                       * @since 1.5.0
  *                                                    *
  * @param array $args Method Parameters.              * @param array $args Method Parameters.
  * @return string                                     * @return int
  */                                                   */
function sayHello($args) {                           function addTwoNumbers($args) {
	       return 'Hello!';                             	       $number1 = $args[0];
}                                                    	       $number2 = $args[1];
                                                     	       return $number1 + $number2;
                                                     }
How to get recent post
function mw_getRecentPosts($args) {

	      $this->escape($args);

	      $blog_ID = (int) $args[0];
	      $username = $args[1];
	      $password = $args[2];
	      if ( isset( $args[3] ) )
	      	        $query = array( 'numberposts' => absint( $args[3] ) );
	      else
	      	        $query = array();

	      if ( !$user = $this->login($username, $password) )
	      	       return $this->error;

	      do_action('xmlrpc_call', 'metaWeblog.getRecentPosts');
How you can use it in your own way
Create your own methods
add_filter( 'xmlrpc_methods', 'add_own_methods' );

function add_own_methods( $methods ) {
           $methods['own.my_method'] = 'own_my_method';

         return $methods
}

function own_my_method( $args ) {
          return $some_data
}
How does it look like
Request
<?xml version="1.0"?>
<methodCall>
<methodName>metaWeblog.getRecentPosts</methodName>
<params>
<param><value><string></string></value></param>
<param><value><string>username</string></value></param>
<param><value><string>password</string></value></param>
</params></methodCall>
Response
<?xml version="1.0"?>
<methodResponse>
  <params>
   <param>
     <value>
     <array><data>
  <value><struct>
  <member><name>dateCreated</name><value><dateTime.iso8601>20110904T18:15:26</dateTime.iso8601></value></member>
  <member><name>userid</name><value><string>1</string></value></member>
  <member><name>postid</name><value><string>1</string></value></member>
  <member><name>description</name><value><string>Welcome to &lt;a href=&quot;http://network.nginx.markoheijnen.com/&quot;&gt;WordPress Network Sites&lt;/a&gt;. This is your first post. Edit or delete it, then start blogging!</
string></value></member>
  <member><name>title</name><value><string>Hello world!</string></value></member>
  <member><name>link</name><value><string>http://test.network.nginx.markoheijnen.com/2011/09/04/hello-world/</string></value></member>
  <member><name>permaLink</name><value><string>http://test.network.nginx.markoheijnen.com/2011/09/04/hello-world/</string></value></member>
  <member><name>categories</name><value><array><data>
  <value><string>Uncategorized</string></value>
</data></array></value></member>
  <member><name>mt_excerpt</name><value><string></string></value></member>
  <member><name>mt_text_more</name><value><string></string></value></member>
  <member><name>mt_allow_comments</name><value><int>1</int></value></member>
  <member><name>mt_allow_pings</name><value><int>1</int></value></member>
  <member><name>mt_keywords</name><value><string></string></value></member>
  <member><name>wp_slug</name><value><string>hello-world</string></value></member>
  <member><name>wp_password</name><value><string></string></value></member>
  <member><name>wp_author_id</name><value><string>1</string></value></member>
  <member><name>wp_author_display_name</name><value><string>marko</string></value></member>
  <member><name>date_created_gmt</name><value><dateTime.iso8601>20110904T18:15:26</dateTime.iso8601></value></member>
  <member><name>post_status</name><value><string>publish</string></value></member>
  <member><name>custom_fields</name><value><array><data>
</data></array></value></member>
  <member><name>wp_post_format</name><value><string>standard</string></value></member>
</struct></value>
</data></array>
     </value>
   </param>
  </params>
</methodResponse>
XML-RPC
Critics of XML-RPC argue that RPC calls can be made with
plain XML
XML-RPC uses about 4 times the number of bytes compared
to plain XML
Need a lot of code on the app side
In the end the size of requests/responses do mather
Is this the best way or
are there alternatives?
Alternatives
Just XML instead of XML-RPC
Use JSON
What is JSON
JavaScript Object Notation
Use JSON as alternative to XML
It is derived from the JavaScript scripting language
Lightweight text-based open standard
Why JSON
Lighter and faster than XML
JSON objects are typed
   Array, object, string, number, boolean and null
Great libraries for mobile platforms
   iOS 5 does have native support for JSON
Easy to parse on mobile platforms
JSON Example
{
        "firstName"    :   "Marko",
        "lastName"     :   "Heijnen",
        "age"          :   25,
        "address"      :   null,
        "newsletter" :     false,
        "phoneNumber" :
        [
            {
               "type" :    "home",
               "number":   "212 555-1234"
            },
            {
               "type" :    "fax",
               "number":   "646 555-4567"
            }
        ]
    }
WordPress doesn’t have
 native support (yet)
Plugins you can use
JSON RPC - http://wordpress.org/extend/plugins/wp-json-
rpc-api/
JSON API - http://wordpress.org/extend/plugins/json-api/
WP RESTful - http://wordpress.org/extend/plugins/wp-
restful/


Be aware that these plugins aren’t up to date
What do I use
JSON API
Great to use because of the use of hooks
Good information on the plugin page
Simple backend interface


I use a modified version of it
   Added consumer key/secret
Interface
How to implement
function add_hello_controller( $controllers ) {
           $controllers[] = 'hello';
           return $controllers;
}
add_filter( 'json_api_controllers', 'add_hello_controller' );

function set_hello_controller_path() {
           return "/path/to/theme/hello.php";
}
add_filter( 'json_api_hello_controller_path', 'set_hello_controller_path' );
How to implement
<?php
class JSON_API_Hello_Controller {
          public function hello_world() {
                return array( "message" => "Hello, world" );
          }
}
?>
Important to know
Only return data that is needed
Return as less HTML as possible
Don’t change the feed without notifying the app developer
A call shouldn’t take to long, speed is everything
Cache the data if possible
   Transients: http://codex.wordpress.org/Transients_API
Recap
How to manage
mobile content
Post types
Add separate meta box for mobile content
   Even the ability to overrule the title
Additional user capability, so not everyone can manage it
Maybe even create a special post type for mobile content
Special admin page
Only for mobile configuration
Store settings
Store default pages for mobile like privacy disclaimer
Push notifications
Create ability to send push notifications in a smart way
   Add to posttype
   Make a separate box on dashboard or admin page
You can handle the sending yourself
Or use for example the services of Urban Airship
Last word
WordPress is a CMS
Can be used in a lot of ways
Sometimes look further then the plugin section
Questions
@markoheijnen / info@markoheijnen.com

Contenu connexe

Tendances

PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP FunctionsAhmed Swilam
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matchingJIGAR MAKHIJA
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHPAhmed Swilam
 
LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners PerlDave Cross
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedAyesh Karunaratne
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Prof. Wim Van Criekinge
 
Introduction to Perl Best Practices
Introduction to Perl Best PracticesIntroduction to Perl Best Practices
Introduction to Perl Best PracticesJosé Castro
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2Kumar
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
 

Tendances (20)

PHP - Introduction to PHP Functions
PHP -  Introduction to PHP FunctionsPHP -  Introduction to PHP Functions
PHP - Introduction to PHP Functions
 
Php string function
Php string function Php string function
Php string function
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
Merb
MerbMerb
Merb
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matching
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners Perl
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
 
DataMapper
DataMapperDataMapper
DataMapper
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Introduction to Perl Best Practices
Introduction to Perl Best PracticesIntroduction to Perl Best Practices
Introduction to Perl Best Practices
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 

En vedette

Nota Makro
Nota MakroNota Makro
Nota Makrogusta100
 
++Lo que recuerdo de la prehistoria gloria
++Lo que recuerdo de la prehistoria gloria++Lo que recuerdo de la prehistoria gloria
++Lo que recuerdo de la prehistoria gloriaMarisolfbc Morales
 
Informe de resultados innovacción 2012
Informe de resultados innovacción 2012Informe de resultados innovacción 2012
Informe de resultados innovacción 2012ArsetInventio
 
Elcometer 3570-casting-knife-film-applicators
Elcometer 3570-casting-knife-film-applicatorsElcometer 3570-casting-knife-film-applicators
Elcometer 3570-casting-knife-film-applicatorsMM Naina Exports
 
Social Media Plan Sinerrata
Social Media Plan SinerrataSocial Media Plan Sinerrata
Social Media Plan SinerrataJudparis
 
Star Advertiser Interview 160114
Star Advertiser Interview 160114Star Advertiser Interview 160114
Star Advertiser Interview 160114Herman Tam
 
Witness tree text analysis
Witness tree   text analysisWitness tree   text analysis
Witness tree text analysisCole Capital
 
Retirement Coach Flyer
Retirement Coach FlyerRetirement Coach Flyer
Retirement Coach Flyerdctyson
 
Competence Assessment Workshop Slides (27.10.14)
Competence Assessment Workshop Slides (27.10.14)Competence Assessment Workshop Slides (27.10.14)
Competence Assessment Workshop Slides (27.10.14)AU Career
 
Fujifilm - Thermoscale film
Fujifilm - Thermoscale filmFujifilm - Thermoscale film
Fujifilm - Thermoscale filmBernard Genoud
 
Estrategias para enseñar a aprender aprender a aprender
Estrategias para enseñar a aprender aprender a aprenderEstrategias para enseñar a aprender aprender a aprender
Estrategias para enseñar a aprender aprender a aprenderNestor Apaza
 
2016.10.14 fb science seed fund na
2016.10.14 fb science seed fund na  2016.10.14 fb science seed fund na
2016.10.14 fb science seed fund na Ana José Varela
 

En vedette (20)

Direccion y liderazgo
Direccion y liderazgoDireccion y liderazgo
Direccion y liderazgo
 
Nota Makro
Nota MakroNota Makro
Nota Makro
 
Kundenrückgewinnung "lost&found"
Kundenrückgewinnung "lost&found"Kundenrückgewinnung "lost&found"
Kundenrückgewinnung "lost&found"
 
++Lo que recuerdo de la prehistoria gloria
++Lo que recuerdo de la prehistoria gloria++Lo que recuerdo de la prehistoria gloria
++Lo que recuerdo de la prehistoria gloria
 
bt Gear de Bio Therapeutic
bt Gear de Bio Therapeutic bt Gear de Bio Therapeutic
bt Gear de Bio Therapeutic
 
Informe de resultados innovacción 2012
Informe de resultados innovacción 2012Informe de resultados innovacción 2012
Informe de resultados innovacción 2012
 
Elcometer 3570-casting-knife-film-applicators
Elcometer 3570-casting-knife-film-applicatorsElcometer 3570-casting-knife-film-applicators
Elcometer 3570-casting-knife-film-applicators
 
Merry web
Merry webMerry web
Merry web
 
Social Media Plan Sinerrata
Social Media Plan SinerrataSocial Media Plan Sinerrata
Social Media Plan Sinerrata
 
Star Advertiser Interview 160114
Star Advertiser Interview 160114Star Advertiser Interview 160114
Star Advertiser Interview 160114
 
5596 5600.output
5596 5600.output5596 5600.output
5596 5600.output
 
Witness tree text analysis
Witness tree   text analysisWitness tree   text analysis
Witness tree text analysis
 
Retirement Coach Flyer
Retirement Coach FlyerRetirement Coach Flyer
Retirement Coach Flyer
 
Competence Assessment Workshop Slides (27.10.14)
Competence Assessment Workshop Slides (27.10.14)Competence Assessment Workshop Slides (27.10.14)
Competence Assessment Workshop Slides (27.10.14)
 
Curriculum vitac
Curriculum vitacCurriculum vitac
Curriculum vitac
 
Advisory Committee Minutes - September 2012
Advisory Committee Minutes  - September 2012Advisory Committee Minutes  - September 2012
Advisory Committee Minutes - September 2012
 
Fujifilm - Thermoscale film
Fujifilm - Thermoscale filmFujifilm - Thermoscale film
Fujifilm - Thermoscale film
 
Estrategias para enseñar a aprender aprender a aprender
Estrategias para enseñar a aprender aprender a aprenderEstrategias para enseñar a aprender aprender a aprender
Estrategias para enseñar a aprender aprender a aprender
 
2016.10.14 fb science seed fund na
2016.10.14 fb science seed fund na  2016.10.14 fb science seed fund na
2016.10.14 fb science seed fund na
 
Comunicado definitivo
Comunicado definitivoComunicado definitivo
Comunicado definitivo
 

Similaire à Creating native apps with WordPress

Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7ZendVN
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersLorna Mitchell
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009cwarren
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applicationselliando dias
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationAlexander Obukhov
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functionsmussawir20
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)Amazon Web Services
 

Similaire à Creating native apps with WordPress (20)

Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
Fatc
FatcFatc
Fatc
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect Partners
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Introduction To Php For Wit2009
Introduction To Php For Wit2009Introduction To Php For Wit2009
Introduction To Php For Wit2009
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
lab4_php
lab4_phplab4_php
lab4_php
 
lab4_php
lab4_phplab4_php
lab4_php
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
 
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generation
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
AWS re:Invent 2016: Chalice: A Serverless Microframework for Python (DEV308)
 

Plus de Marko Heijnen

Custom coded projects
Custom coded projectsCustom coded projects
Custom coded projectsMarko Heijnen
 
Security, more important than ever!
Security, more important than ever!Security, more important than ever!
Security, more important than ever!Marko Heijnen
 
My Contributor Story
My Contributor StoryMy Contributor Story
My Contributor StoryMarko Heijnen
 
WooCommerce & Apple TV
WooCommerce & Apple TVWooCommerce & Apple TV
WooCommerce & Apple TVMarko Heijnen
 
The moment my site got hacked - WordCamp Sofia
The moment my site got hacked - WordCamp SofiaThe moment my site got hacked - WordCamp Sofia
The moment my site got hacked - WordCamp SofiaMarko Heijnen
 
Mijn site beveiliging
Mijn site beveiligingMijn site beveiliging
Mijn site beveiligingMarko Heijnen
 
The moment my site got hacked
The moment my site got hackedThe moment my site got hacked
The moment my site got hackedMarko Heijnen
 
My complicated WordPress site
My complicated WordPress siteMy complicated WordPress site
My complicated WordPress siteMarko Heijnen
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Protecting your site by detection
Protecting your site by detectionProtecting your site by detection
Protecting your site by detectionMarko Heijnen
 
GlotPress aka translate.wordpress.org
GlotPress aka translate.wordpress.orgGlotPress aka translate.wordpress.org
GlotPress aka translate.wordpress.orgMarko Heijnen
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable codeMarko Heijnen
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 
Let's create a multilingual site in WordPress
Let's create a multilingual site in WordPressLet's create a multilingual site in WordPress
Let's create a multilingual site in WordPressMarko Heijnen
 
Bootstrapping your plugin
Bootstrapping your pluginBootstrapping your plugin
Bootstrapping your pluginMarko Heijnen
 
The development and future of GlotPress
The development and future of GlotPressThe development and future of GlotPress
The development and future of GlotPressMarko Heijnen
 
Why Javascript matters
Why Javascript mattersWhy Javascript matters
Why Javascript mattersMarko Heijnen
 
The code history of WordPress
The code history of WordPressThe code history of WordPress
The code history of WordPressMarko Heijnen
 
Building plugins like a pro
Building plugins like a proBuilding plugins like a pro
Building plugins like a proMarko Heijnen
 
Perfect your images using WordPress - WordCamp Europe 2013
Perfect your images using WordPress - WordCamp Europe 2013Perfect your images using WordPress - WordCamp Europe 2013
Perfect your images using WordPress - WordCamp Europe 2013Marko Heijnen
 

Plus de Marko Heijnen (20)

Custom coded projects
Custom coded projectsCustom coded projects
Custom coded projects
 
Security, more important than ever!
Security, more important than ever!Security, more important than ever!
Security, more important than ever!
 
My Contributor Story
My Contributor StoryMy Contributor Story
My Contributor Story
 
WooCommerce & Apple TV
WooCommerce & Apple TVWooCommerce & Apple TV
WooCommerce & Apple TV
 
The moment my site got hacked - WordCamp Sofia
The moment my site got hacked - WordCamp SofiaThe moment my site got hacked - WordCamp Sofia
The moment my site got hacked - WordCamp Sofia
 
Mijn site beveiliging
Mijn site beveiligingMijn site beveiliging
Mijn site beveiliging
 
The moment my site got hacked
The moment my site got hackedThe moment my site got hacked
The moment my site got hacked
 
My complicated WordPress site
My complicated WordPress siteMy complicated WordPress site
My complicated WordPress site
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Protecting your site by detection
Protecting your site by detectionProtecting your site by detection
Protecting your site by detection
 
GlotPress aka translate.wordpress.org
GlotPress aka translate.wordpress.orgGlotPress aka translate.wordpress.org
GlotPress aka translate.wordpress.org
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable code
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 
Let's create a multilingual site in WordPress
Let's create a multilingual site in WordPressLet's create a multilingual site in WordPress
Let's create a multilingual site in WordPress
 
Bootstrapping your plugin
Bootstrapping your pluginBootstrapping your plugin
Bootstrapping your plugin
 
The development and future of GlotPress
The development and future of GlotPressThe development and future of GlotPress
The development and future of GlotPress
 
Why Javascript matters
Why Javascript mattersWhy Javascript matters
Why Javascript matters
 
The code history of WordPress
The code history of WordPressThe code history of WordPress
The code history of WordPress
 
Building plugins like a pro
Building plugins like a proBuilding plugins like a pro
Building plugins like a pro
 
Perfect your images using WordPress - WordCamp Europe 2013
Perfect your images using WordPress - WordCamp Europe 2013Perfect your images using WordPress - WordCamp Europe 2013
Perfect your images using WordPress - WordCamp Europe 2013
 

Dernier

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 

Dernier (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Creating native apps with WordPress

  • 1. Creating native apps with WordPress Marko Heijnen January 14, 2012 at WordCamp Norway
  • 2. Marko Heijnen Freelance developer Mobile / WordPress http://markoheijnen.com info@markoheijnen.com @markoheijnen
  • 3. History 2006: Started with WordPress 2009: Started with iOS development 2010: First patch to WordPress ( 3.0 ) 2011: Combined iOS development with WordPress 2012: First WordCamp presentation
  • 5. Mobile is the growing
  • 6. There is a change you get involved with it
  • 7. Native app vs Web app/site
  • 8. Native vs mobile Build a native app when: People are going to use it quite often ( daily basis ) Features that aren’t possible for web ( yet ) A lot of users request for it ( 10.000 > ) Customers really want an app
  • 10. What does it mean for you You need to communicate with another developer Need to build an API that the developer can use So you need to understand what a mobile developer wants Need to build additional fields in WordPress for information that the mobile app can use
  • 12.
  • 13. API of the app WordPress for iOS uses XML-RPC WordPress support it by default Supports: Blogger API, metaWeblog API, and the Movable Type API
  • 14. Where can you find it /xmlrpc.php handles the request /wp-includes/class-wp-xmlrpc.server.php Registers all the default methods
  • 15. Methods for testing /** /** * Test XMLRPC API by saying, "Hello!" to client. * Test XMLRPC API by adding two numbers for client. * * * @since 1.5.0 * @since 1.5.0 * * * @param array $args Method Parameters. * @param array $args Method Parameters. * @return string * @return int */ */ function sayHello($args) { function addTwoNumbers($args) { return 'Hello!'; $number1 = $args[0]; } $number2 = $args[1]; return $number1 + $number2; }
  • 16. How to get recent post function mw_getRecentPosts($args) { $this->escape($args); $blog_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; if ( isset( $args[3] ) ) $query = array( 'numberposts' => absint( $args[3] ) ); else $query = array(); if ( !$user = $this->login($username, $password) ) return $this->error; do_action('xmlrpc_call', 'metaWeblog.getRecentPosts');
  • 17. How you can use it in your own way
  • 18. Create your own methods add_filter( 'xmlrpc_methods', 'add_own_methods' ); function add_own_methods( $methods ) { $methods['own.my_method'] = 'own_my_method'; return $methods } function own_my_method( $args ) { return $some_data }
  • 19. How does it look like
  • 21. Response <?xml version="1.0"?> <methodResponse> <params> <param> <value> <array><data> <value><struct> <member><name>dateCreated</name><value><dateTime.iso8601>20110904T18:15:26</dateTime.iso8601></value></member> <member><name>userid</name><value><string>1</string></value></member> <member><name>postid</name><value><string>1</string></value></member> <member><name>description</name><value><string>Welcome to &lt;a href=&quot;http://network.nginx.markoheijnen.com/&quot;&gt;WordPress Network Sites&lt;/a&gt;. This is your first post. Edit or delete it, then start blogging!</ string></value></member> <member><name>title</name><value><string>Hello world!</string></value></member> <member><name>link</name><value><string>http://test.network.nginx.markoheijnen.com/2011/09/04/hello-world/</string></value></member> <member><name>permaLink</name><value><string>http://test.network.nginx.markoheijnen.com/2011/09/04/hello-world/</string></value></member> <member><name>categories</name><value><array><data> <value><string>Uncategorized</string></value> </data></array></value></member> <member><name>mt_excerpt</name><value><string></string></value></member> <member><name>mt_text_more</name><value><string></string></value></member> <member><name>mt_allow_comments</name><value><int>1</int></value></member> <member><name>mt_allow_pings</name><value><int>1</int></value></member> <member><name>mt_keywords</name><value><string></string></value></member> <member><name>wp_slug</name><value><string>hello-world</string></value></member> <member><name>wp_password</name><value><string></string></value></member> <member><name>wp_author_id</name><value><string>1</string></value></member> <member><name>wp_author_display_name</name><value><string>marko</string></value></member> <member><name>date_created_gmt</name><value><dateTime.iso8601>20110904T18:15:26</dateTime.iso8601></value></member> <member><name>post_status</name><value><string>publish</string></value></member> <member><name>custom_fields</name><value><array><data> </data></array></value></member> <member><name>wp_post_format</name><value><string>standard</string></value></member> </struct></value> </data></array> </value> </param> </params> </methodResponse>
  • 22. XML-RPC Critics of XML-RPC argue that RPC calls can be made with plain XML XML-RPC uses about 4 times the number of bytes compared to plain XML Need a lot of code on the app side In the end the size of requests/responses do mather
  • 23. Is this the best way or are there alternatives?
  • 24. Alternatives Just XML instead of XML-RPC Use JSON
  • 25. What is JSON JavaScript Object Notation Use JSON as alternative to XML It is derived from the JavaScript scripting language Lightweight text-based open standard
  • 26. Why JSON Lighter and faster than XML JSON objects are typed Array, object, string, number, boolean and null Great libraries for mobile platforms iOS 5 does have native support for JSON Easy to parse on mobile platforms
  • 27. JSON Example { "firstName" : "Marko", "lastName" : "Heijnen", "age" : 25, "address" : null, "newsletter" : false, "phoneNumber" : [ { "type" : "home", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ] }
  • 28. WordPress doesn’t have native support (yet)
  • 29. Plugins you can use JSON RPC - http://wordpress.org/extend/plugins/wp-json- rpc-api/ JSON API - http://wordpress.org/extend/plugins/json-api/ WP RESTful - http://wordpress.org/extend/plugins/wp- restful/ Be aware that these plugins aren’t up to date
  • 30. What do I use
  • 31. JSON API Great to use because of the use of hooks Good information on the plugin page Simple backend interface I use a modified version of it Added consumer key/secret
  • 33. How to implement function add_hello_controller( $controllers ) { $controllers[] = 'hello'; return $controllers; } add_filter( 'json_api_controllers', 'add_hello_controller' ); function set_hello_controller_path() { return "/path/to/theme/hello.php"; } add_filter( 'json_api_hello_controller_path', 'set_hello_controller_path' );
  • 34. How to implement <?php class JSON_API_Hello_Controller { public function hello_world() { return array( "message" => "Hello, world" ); } } ?>
  • 35. Important to know Only return data that is needed Return as less HTML as possible Don’t change the feed without notifying the app developer A call shouldn’t take to long, speed is everything Cache the data if possible Transients: http://codex.wordpress.org/Transients_API
  • 36. Recap
  • 38. Post types Add separate meta box for mobile content Even the ability to overrule the title Additional user capability, so not everyone can manage it Maybe even create a special post type for mobile content
  • 39. Special admin page Only for mobile configuration Store settings Store default pages for mobile like privacy disclaimer
  • 40. Push notifications Create ability to send push notifications in a smart way Add to posttype Make a separate box on dashboard or admin page You can handle the sending yourself Or use for example the services of Urban Airship
  • 41. Last word WordPress is a CMS Can be used in a lot of ways Sometimes look further then the plugin section