I have been working on a program in python that I want to make available to paid subscribers via REST. I’m currently thinking of having the frontend made in WordPress and then host the backend somewhere else.
In wordpress there are a bunch of plugins to handle paid subscribers and so on and everything seems great but my concern is how do I verify this on the backend that is hosted somewhere else?
If I use Django, is there any way I can make some kind of call to the WordPress server(?) and verify that the user that is trying to fetch items are an paid subscriber?
I made a Diagram to kind of show what I mean. Basically B should only answer back with items if the caller A is a paid subscriber.
I’ve read that it is possible to generate an API key that will be needed in order to fetch data from the API, I’ve also read ways of hiding this call from the frontend to the backend from the user by using some kind of relay on wordpress. Might be wrong here.
Is there any preferred way of doing this?
Is Django REST & WordPress suitable options to do this?
2
Answers
In programming almost anything is possible. However, since wordpress is built in php I would not say that it would be possible to work directly with it. But, (MAYBE) you can connect the wordpress database to django for READ only and create an api.
How I would do it if I had this task:
Connect Django to an existing db (your wordpress db):
Since you created the models you can create your endpoints:
paid_subscriber = True
or paid_subscriber = 1. Certainly it will be there.I think the only issue you will have is to connect with the wordpress database. After you have done this in django nothing can stop you to create endpoints with
django-rest-framework
displaying the data it has.You can do that using the Django REST framework(DRF) which is used for such purpose for making the rest API’s.
As per your query i would suggest you to the DRF to read the data from wordpress database and perform the validation on top of it.
Here are some links that you can use for reference :-