Calling a Composr API function "in batch mode"

Post

Posted
Rating:
#7598 (In Topic #1912)

I would like to call the add_news function in the news package from a php script launched by a Cron job

Hello all.  First off, apologies!  I am brand new to Composr.  I also have not been able to simply figure out how to search the forum for previously asked topics -- I hope I'm not wasting peoples' time.

I have almost completed an ETL implementation that will basically gather a bunch of news articles from various sources (the extract), scrub the article text and meta data into a common format (the transform), and I now would like to add these articles, "unvalidated", via an api call to the add_news function in the news package (the load).

The purpose of the ETL implementation is to run on a scheduled basis (using Cron), with the end result being that our Composr administrator simply needs to check the resultant queue of articles not yet validated.  At that point, the administrator will choose to either validate / publish or discard each article in the queue.  Hence, this is by design a background process.

I'm looking for any sort of sample that someone has written to do this sort of thing?

Thanks in advance.

Bob


 

Post

Posted
Rating:
#7602
While I don't have a sample I can provide, perhaps consider writing a Commandr script which can be executed via Cron.

See

Composr Tutorial: Commandr

Open Source CMS with advanced social, interactive and dynamic features. Fully flexible, themeable and extendible: suitable for building powerful websites.

View

.

Essentially, you would create a file (no extension) in your Composr installation under data/modules/admin_commandr (or /bin if using webDAV or Commandr directly to create the file).

Prefix the file contents with a : to enter PHP mode. And you can write in your PHP script as necessary. For example, you'll need to require_code("news2"); to gain access to the add_news function, which you can then call later down in the script.

Once your script is written and saved, you can create a Cron that calls the script via a web request (you cannot use PHP cli because the script requires a POST parameter). Call data/commandr.php and POST command=name_of_script_file.
 

Last edit: by PDStig

0 guests and 0 members have recently viewed this.