Serge
Serge

Reputation: 741

How to execute PHP script from CLI in browser-like way using wget or curl

I have PHP script what works fine via browser like

http://example.com/index.php?option=com_acymailing&view=api

Is that possible to call the same using WGET or CURL from Linux CLI (ignoring any output, just run "like browser" and close) ?

Thanks in advance for any hint to try.

The script from Joomla AcyMailing API and here is full content

<?php

define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
 include_once dirname(__FILE__) . '/defines.php';
}

if (!defined('_JDEFINES')) {
 define('JPATH_BASE', dirname(__FILE__));
 require_once JPATH_BASE.'/includes/defines.php';
}

require_once JPATH_BASE.'/includes/framework.php';
$app = JFactory::getApplication('site');


if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
 echo 'This code can not work without the AcyMailing Component';
 return false;
 }
$mailer = acymailing_get('helper.mailer');
$mailer->report = true;
$mailer->trackEmail = true;
$mailer->autoAddUser = false;
$mailer->sendOne(11,'[email protected]');

?>

Upvotes: 2

Views: 1386

Answers (1)

twicejr
twicejr

Reputation: 1329

Yes, it is possible in many ways. If you want to ignore any output:

wget --quiet -O /dev/null http://whatever-url/script.php?bla

Upvotes: 2

Related Questions