如何使用wget或curl以类似浏览器的方式从CLI执行PHP脚本


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

我有一个PHP脚本,可以通过浏览器正常工作,如

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

是否可以使用WGET或CURL从Linux命令行调用相同的(忽略任何输出,只是运行"like browser"并关闭)?

提前感谢任何提示尝试。

来自Joomla AcyMailing API的脚本,这里是完整的内容

<?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,'test@example.com');
?>

是的,在很多方面都是可能的。如果您想忽略任何输出:

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