How are you using the API in 2.1 with Wordpress?

Brent W

Well-known member
Is anyone using the new API with Wordpress? I am beginning to look into using it to create a thread when a Post or Page is created under certain circumstances.

When a post or page is created two things would happen:
  1. The thread id or url of the new thread would be stored in a custom field so that it can be linked to in the post or page
  2. The thread will be created in a forum based on which post or page is being created.
If anyone has done something like this already would be awesome if you could share.
 

Brent W

Well-known member
Bump. If not this specifically, as anyone created a plug in that has basic API connection?
 

vbresults

Well-known member
Under the assumption that both your WordPress and XenForo installs are on the same server, what you are trying to accomplish has nothing to do with the 2.1 REST API. You need a custom WordPress plugin on one end, and a XenForo add-on on the other.

If they are not on the same server, then you need a custom WordPress plugin on one end, and the REST API on the XenForo side.
 
Last edited:

Brent W

Well-known member
Both are on the same server and I've created a simple plugin that uses the 2.1 REST API to create a new thread when the post or page is created. It creates the thread, the thread links back to the post or page and the post or page links to the thread. I have very simple requirements where only one user is creating the thread so only one user API key needs to be created with threads permissions.
 

vbresults

Well-known member
Using the new REST API to connect a local WordPress install like this, is like trying to use a new courier service to mail someone next door. You can do it, I guess, but that's not the intended or optimal use of the system.

The REST API is for things like transmitting data to and from mobile apps, and single sign-on where the CMS and XenForo reside on different servers. The most practical method of communication in that case is a REST API.

Many confuse REST API with API. REST is a remote way to access an API which has always been available to other software on the same web server.
 

Brent W

Well-known member
Sometimes I think people overthink things. I've done this with very little code. Simply include Guzzle (and if you really wanted to be rough just use curl itself), when new post or page is created in Wordpress I make one API call to create the new thread. Use the response to get the new thread id and then create a url to the thread and store it in Wordpress so it can be referenced by the post.

If you want to include XenForo files to just do this go for it. The API makes this easy as can be. I said it was simple and to the point and works for me. It doesn't do anything more than I need it to do. So it is perfect.

I don't care about Permissions or anything like that. I simply want to create one thread when one post is created. Simple.
 

vbresults

Well-known member
We can more make a much more solid opposing case. People often don't think things through enough. There is a reason why it's so easy to create a new thread, but linking up the content is so puzzling. Wrong tool for this job.

I understand the confusion from a client's side. @Mike I wonder if the requests for an API got picked up and misinterpreted by non-developers who were really looking for a bridge in it's various forms, and was mistaken for mass-market API demand.

I'm sure that didn't happen, but if it did, I'd be pulling my hairs out 😵
 

Brent W

Well-known member
I mean, you can make all the opposing case you'd like. It works and it works perfect.

I have already said I don't want a bridge. I don't want Wordpress and XenForo to be linked in ANY other way than this. I don't need permission checks. I don't need to use any bit of XenForo code, really. I just need it to create a thread and be able to reference that thread in certain areas of my site.
 
Top