Jump to content

Recommended Posts

Posted

Hi there,
 
I have 4 systems:

  • system1: an independent processwire installation 2.5.3 with own database
  • system2: an independent processwire installation 2.5.3 with own database
  • system3: an independent processwire installation 2.5.3 with own database
  • cronjobsystem: In a cronjob I want to access the processwire database from the systems with the easy Processwire API access

On the cronjobsystem:
Downloaded processwire, but I just want this system to use the easy API and to change the database dynamically to system 1-3.
On the server there is just

  • index.php
  • the wire folder.

Is this possible:

$config = new Config();
$config->dbHost = IP_SYSTEM1
$config->dbName = DBNAME_SYSTEM1
$config->dbPass = DBPASS_SYSTEM1
$config->dbPort = 3306;

include("index.php");
 
$pages_system1 = wire()->find("template=article");
var_dump($pages_system1);

Questions:
- Is this possible or what is the best way to achieve using the easy API access while the database comes from another system?
- How can I initiate the class autoloader on the cronjobsystem?
 
Thank you,
Chris

Posted

Hi Nico, thank you for your reply.

It's three PW installations with three own databases.

I don't want to access the asset folder, I just want to change some data inside the database with the ease of PW (e.g. page titles, some fields, ...)

No file up or downloads.

The module you suggested is the right direction!

But it doesn't look like I can change data with it as well!?

Posted

It's really easy actually. Just do the following for every installation (of course you have to secure it a lot more):

1. Create a new template called "api"

2. create a new page called "api" using that template

-> Now you can open http://yoursite.com/api/

In the template file api.php you can for example process post or get parameters. 

Example:

http://yoursite.com/api/?action=addPage

And in your template file you have:

if($_GET['action'] == "addPage") {
// create page via api

}

And so on.

Posted

I thought about a solution like this as well but I want to avoid writing API Endpoints.

Just want the full control of the system and change data on other systems without adding new code.

Posted

It's really easy actually. Just do the following for every installation (of course you have to secure it a lot more):

1. Create a new template called "api"

2. create a new page called "api" using that template

-> Now you can open http://yoursite.com/api/

In the template file api.php you can for example process post or get parameters. 

Example:

http://yoursite.com/api/?action=addPage

And in your template file you have:

if($_GET['action'] == "addPage") {
// create page via api

}

And so on.

I would do it like Nico wrote above...

Requests should restricted to source ip address for security reasons.

You have to write some code. Also your way won't work without custom code.

So write a simple API and send needed params via GET sounds good.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...