狠狠撸

狠狠撸Share a Scribd company logo
WhattheWordPressRESTAPI
meansforJavascriptDevelopers
JakeSpurlock
@whyisjake
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
Hi
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
Node.js
What the WordPress REST API Means for Javascript Developers
Wait,what?
FAST
NODE IS
php.JS
WordPress.JS
Chipotle.JS
// Let’s get this burrito bowl going…
chipotle.create({
type: 'bowl',
options: {
rice: 'white',
beans: 'pinto',
meat: 'chicken',
salsa: [
'green',
‘corn'
],
cream: true,
cheese: true,
guacamole: true,
notes: 'Extra guac please!’
}
});
What the WordPress REST API Means for Javascript Developers
WPAPI
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
WIRED
EXPRESS
https://www.npmjs.com/package/wpapi
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
github.com/whyisjake/wired-express
CRUD
Build an “App”
10K+CONCURRENT VIEWERS
WIRED.COM LIVEBLOGS
What about
Tumblr?
RE-EVALUATE LIVEBLOGS
Complexity.
What the WordPress REST API Means for Javascript Developers
Simple
// Let's loop through each one, and add the response to post
meta.
// As we get posts, also push those to the main $posts array.
// Reversing this so that we have some better logic for
updating posts.
// Ideally, you don't need to loop through every page, you
could just
// update the most recent page or two.
for ( $i = 0; $i < $times; $i++ ) {
// Fetch a batch of posts
$response = $this->fetch_and_parse( $url, $i );
$more_posts = $response['response']['posts'];
$more_posts = $this->clean_tumblr_response( $more_posts );
if ( ! empty( $more_posts ) ) {
update_post_meta( $post_id, 'liveblog_posts_page_' . $i,
$more_posts );
}
// Add each of the posts to the main post array.
foreach ( $more_posts as $post ) {
$posts[] = $post;
}
}
This is silly.
Make posts,damnit.
Slack
What the WordPress REST API Means for Javascript Developers
What the WordPress REST API Means for Javascript Developers
Livebot
Livebotisanodeapplicationthatlistensfor
requestsfromSlackandrespondswithrequests
toaWordPressRESTAPIendpointtomanage
liveblogposts.Theapplicationisbestthoughtof
asamiddlewarethattranslatesrequestsbetween
theSlackserverandWordPress.Theapplication
itselfhasnoexternaldependencies(e.g.,
database,cache),makingtheapplicationvery
easytorun.
Sunstone
?30+years
?3500sessions
?Thousandsofpresenters
Sunstone
What the WordPress REST API Means for Javascript Developers
JakeSpurlock
@whyisjake

More Related Content

What the WordPress REST API Means for Javascript Developers