2

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]');

?>
5
  • 6
    Short answer: Yes. Long answer: Have you tried it? Commented Nov 16, 2016 at 17:11
  • If you are relying on JavaScript to run, then no. Otherwise yes. Commented Nov 16, 2016 at 17:12
  • Good if yes. So my logic question HOW ? and then I try. Commented Nov 16, 2016 at 17:13
  • pure php can be....here is something you might be looking stackoverflow.com/questions/6965541/… and you need something like $ wget -O - -q http://www.somesite.com/your.php >> log.txt log.txt would include the result Commented Nov 16, 2016 at 17:14
  • Unfortunately not. I've added this script - may be it will explain something. Commented Nov 16, 2016 at 17:28

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

8 Comments

Unfortunately not. When run from browser - this script produces an email to single user. When run from CLI using your way - not.
@Serge Then your script is doing some sort of check or expects input. Before you post more relevant information, we cannot help you.
Charlotte, that's my thoughts exactly. Probably check the remote_addr usage. Or some other obscure $_SERVER remote address variant
Also, at first don't trash the output; just use wget [url], and check the output for errors.
Yes, after some tests I see the script should be adjusted itself to use with curl or wget, so I delete my question because it's not the matter of curl or wget...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.