that’s just a first sketch - should work as it is - but I think there are several parts missing for a final solution. I will collect ideas here and build the final one if there is enough interest
Right now - to test it:
Create a new directory in the wp-content/plugins/ folder of your WordPress installation and name it “tinderbox_rest”
Inside the new directory, create a PHP file with the same name as the plugin folder: “tinderbox_rest.php” and copy the code into the file. Now you can activate the new plugin in Wordpress. Create a category named “tinderbox” in Wordpress.
create a new stamp in Tinderbox and copy the TBX code to the stamp. That’s it.
Run the stamp on any note of your TBX file and it should appear as a new post in your wordpress install.
P.S.: and you need to enter the url to your Wordpress install followed by “/tinderbox-plugin/v1” into the restURL variable.
P.P.S.: the easiest way to run Wordpress for testing stuff like this is Mamp Pro
Thank you very much for these instructions. I will give it a try. I always wanted to be able to publish to WordPress (and also edit previously posted notes). Adding a Tinderbox plugin on the WordPress side seems to be much smarter than trying to go through xmlrpc.php.
I believe the new fetch operator in 9.6 will make this simpler. Just wanted to point out that fetch(), though most often used to GET data, can also POST.
This is awesome, but I can’t seem to get it to work. I wonder if my ISP is blocking it. Also, I wonder if there is any additional security that we can pt into this concept to ensure that only authorized people can post to it.
I removed some older posts here - too many updates…
Here is the latest version of the Tinderbox sample file and the Wordpress PlugIn.
The PlugIn offers three functions to be used with Tinderbox:
create a post in Wordpress from any note in TBX
update the title and text of the post from TBX
delete the post directly out of TBX
To add a basic amount of security there is a parameter called “secret”. Enter any value you like - but take care you use the same string in Wordpress and TBX. In Wordpress there is an admin area for that task:
There you also can set the user the posts should belong to.
Every new post in Wordpress will get the category “Tinderbox”. This may help filtering the posts in Wordpress. And the delete function will only delete posts with this category.
It works fine here for me. You may run into problems if you use a security plugin like Wordfence. They often block any traffic to the REST interface of Wordpress.
Here is an update of the TBX demo file - using the fetch() command of 9.6 (the former version runs with 9.5 and 9.6).
Also now we have a preference note where you enter your URL to the Wordpress host and your secret.
OK. I have been able to workaround this by creating the category “Tinderbox” manually first in the target WordPress site.
It is a good move to check for the existence and trying to create the category as it presents a way to create categories from Tinderbox by adding a “Wordpress_Category” attribute to a note. Somehow the call to wp_create_category() in the tinderbox_rest_plugin_create_tbx_category()-function of your plugin does not work in my environment.
thanks a lot for your log file - I restructured the files of the plugin and placed the wp_create_category() in the wrong place. I will release an update later today!
The category is important - to filter the posts later or, I’m doing this already in the PlugIn, check for the category when deleting an entry.
here is a new version of the plugin with a fix for the wp_create_category() bug (the function got removed from the current WP version).
And I will return to the CURL version of the TBX file. The new fetch() command has a limitation since the length of the called URL is limited. So large notes will not get passed to WP - no problem with CURL. This is not a bug but a feature of fetch().
And here is a new version of the demo - with two version of the CreatePostInWP stamp. The one with CURL works fine even with larger notes. The one with fetch only with a limited number of characters.
I tested my Wordpress PlugIn with a TBX file - a note with a long text will not go thru - with CURL it will. POST has no limit itself (as far as I know) but all browser do have one. So it depends on the lib you are using I guess. If I shorten the text the same note will be processed without a problem
(1) great!!!
(2) I don’t think it is an encoding problem. I just have to reduce the amount of characters and the fetch() call has no problems. But I don’t get an error message so this is a wild guess only…
OK: the problem appears to be encoding after all. Specifically, is “/” allowed in a query? Just at the moment, I have Apple saying "sure!” and Wikipedia saying “absolutely not!”. And another part of the Apple API says “no way!”