【发布时间】:2016-11-16 17:07:17
【问题描述】:
我有 PHP 脚本,通过浏览器可以正常工作
http://example.com/index.php?option=com_acymailing&view=api
是否可以使用 Linux CLI 中的 WGET 或 CURL 调用相同的方法(忽略任何输出,只需“像浏览器一样”运行并关闭)?
提前感谢任何提示尝试。
来自 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');
?>
【问题讨论】:
-
简短回答:是的。长答案:你试过吗?
-
如果你依赖 JavaScript 来运行,那么没有。否则是的。
-
如果是的话很好。所以我的逻辑问题如何?然后我试试。
-
纯 php 可以......这是你可能正在寻找的东西 stackoverflow.com/questions/6965541/… 并且你需要像
$ wget -O - -q http://www.somesite.com/your.php >> log.txt这样的东西 log.txt 将包含结果 -
很遗憾没有。我已经添加了这个脚本 - 也许它会解释一些东西。
标签: php curl command-line-interface wget