idawnwon
Posted on January 20, 2021
After explored WordPress, I found it is really an easy-to-use yet powerful CMS backend. I decided to use Flutter to develop a front-end, CRUD data directly from WordPress through API.
1. Configure "JWT Authentication for WP-API"
This is a plugin for WordPress.
1.1 Search and Download "JWT Authentication for WP-API" in WordPress Plugin Market. (DON'T activate it for now.)
1.2 Edit .htaccess
file, add lines below, between <IfModule mod_rewrite.c>
and </IfModule>
tag.
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
1.3 Edit wp-config.php
file, add lines below, right after define('AUTH_KEY', '...');define('SECURE_AUTH_KEY', '...');define('LOGGED_IN_KEY', '...');define('NONCE_KEY', '...');define('AUTH_SALT', '...');define('SECURE_AUTH_SALT', '...');define('LOGGED_IN_SALT', '...');define('NONCE_SALT', '...');
define('JWT_AUTH_SECRET_KEY', 'YOUR_KEY_HERE');
define('JWT_AUTH_CORS_ENABLE', true);
Replace 'YOUR_KEY_HERE'
with your key. Strongly recommend you to get one random key at this trusted site.
Just copy anyone you like.
1.4 Activate "JWT Authentication for WP-API" in your WordPress panel.
2. Edit pubspec.yaml file
This file locates in your flutter project folder.
Add following lines under dependencies:
block:
flutter_wordpress: ^0.2.0
flutter_html: ^1.1.0
url_launcher: ^5.7.10
The version numbers are not constant. I googled each one's latest version on November 24, 2020. Maybe there would be newer versions at the time you are reading here.
Thanks to Morten Rand-Hendriksen's tutorial on Lynda.com
Hope this helps!
So proud to be a coder!
Posted on January 20, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.