26
Centralizing News through WordPress REST API Todd McKee, MEd University of Arkansas for Medical Sciences (UAMS)

Centralizing News through WordPress REST API

Embed Size (px)

Citation preview

Page 1: Centralizing News through WordPress REST API

Centralizing News through WordPress REST API

Todd McKee, MEd University of Arkansas for Medical Sciences (UAMS)

Page 2: Centralizing News through WordPress REST API

Todd McKee, MEd @toddmckee

Senior Web Developer Office of Communications and Marketing

Page 3: Centralizing News through WordPress REST API

Wordpress at UAMS

• UAMSHealth.com (Hospital & News) • 9000+ posts & pages

• uamsonline.com & uamsonlinedev.com (UAMS multisites) • 150 sites with ~400 users

• uamsonlinetwo.com & uamsdev.com (Institutes) • 7 sites with 1500+ posts

• sites.uams.edu & go.uams.edu (One-offs & Apps) • ~30 sites with ~200 users

• 25+ of single installs (One-offs & special)

Page 4: Centralizing News through WordPress REST API
Page 5: Centralizing News through WordPress REST API

Before

College of Medicine

Research

Cancer Institute

Same (-ish) Story. Posted 3 times or more

✂+📋

✂+📋

✂+📋

Page 7: Centralizing News through WordPress REST API

Now

College of Medicine

Same Story. Not all sites are available

Cancer Institute

Research

Push

🚫

Page 8: Centralizing News through WordPress REST API

LEVEL UP: Merging All The Things

https://online.wpcampus.org/schedule/level-up-centralized-news-and-wordpress/

Page 9: Centralizing News through WordPress REST API

Now

Cancer Institute

College of Medicine

Research

Push

🚫

Page 10: Centralizing News through WordPress REST API

Soon

Cancer Institute

College of Medicine

ResearchOne Story. Multiple sites

Pull

(Already Started)

Page 11: Centralizing News through WordPress REST API
Page 12: Centralizing News through WordPress REST API

• https://wpengine.com/resources/the-ultimate-guide-to-the-wordpress-rest-api/

• https://torquemag.io/2017/05/ways-start-using-wp-rest-api/

• https://jeremyfelt.com/2016/02/17/using-wp-rest-api-washington-state-university/

• https://github.com/washingtonstateuniversity/WSUWP-Content-Syndicate

Page 13: Centralizing News through WordPress REST API
Page 14: Centralizing News through WordPress REST API

WHAT IS AN API?

Definition: Application Program Interface (API) is a set of routines, protocols, and tools

for building software applications.

YOU LOST ME AT “DEFINITION”

An API lets you access, or create data. WordPress Terms: The REST API lets you access, or

create, WordPress content.

https://www.slideshare.net/royssivan/wpcampus-online-the-case-for-the-wordpress-rest-api

Page 15: Centralizing News through WordPress REST API

HOW DO YOU API?

Leveraging the API isn’t that difficult once you get the hang of JSON (JavaScript Object

Notation) Use JavaScript or PHP

RESTful APIRepresentational state transfer (REST) or RESTful web services is an API that uses HTTP requests to GET, PUT, POST and DELETE data (Universal connector for data).

Page 16: Centralizing News through WordPress REST API

JSON

Page 17: Centralizing News through WordPress REST API

WP Rest API 101

• WordPress 4.7+

• v2.wp-api.org

• CRUD (Create, Read, Update, Delete)

• /wp-json/wp/v2/

https://www.slideshare.net/AndrewDixon5/an-absolute-beginners-guide-to-the-wordpress-rest-api

Page 18: Centralizing News through WordPress REST API

GET

• /wp-json/wp/v2/posts

• Example

Page 19: Centralizing News through WordPress REST API

Filter

• Add parameters to filter

• Think WP-Query

• GET

• /wp-json/wp/v2/posts?search=awesome

• /wp-json/wp/v2/posts?page=1&per_page=2

• Example

Page 20: Centralizing News through WordPress REST API

Single Article

• GET /wp-json/wp/v2/posts/{POST-ID}

• Example

Page 21: Centralizing News through WordPress REST API

What else can we access?

• Pages

• Media

• Custom Post Types

• Taxonomies

• Everything…

Page 22: Centralizing News through WordPress REST API

Examples

Page 23: Centralizing News through WordPress REST API

Issues

• Authentication

• Basic, JavaScript, & Oauth

• Cross-Origin Resource Sharing (CORS)

• Extending Support For Custom Content Types

Page 24: Centralizing News through WordPress REST API

What are we doing?

• News on www.uams.edu

• Image on top of www.uams.edu

• Alert system (WP API v1)

• People / Physician directory (coming soon)

Page 25: Centralizing News through WordPress REST API

Thank you.

Questions?

Page 26: Centralizing News through WordPress REST API

Resources

• github.com/UAMS-Web

• github.com/UAMS-Web/UAMSWP-Content-Syndication

• github.com/washingtonstateuniversity

• wpcampus.org