How to make webservice run without user interaction?

2

So, I'm trying to create a webservice in PHP that will do everything through another webservice (for its API). It will check if it has any messages, having, it processes and returns an appropriate message.

My question is: How to make this webservice run?

It has to run automatically, by itself. I do not know how to do this in PHP.

I know there are more appropriate languages for what I want, but PHP is what I have right now.

Any light?

    
asked by anonymous 30.05.2015 / 03:02

3 answers

1

To do what you want PHP will need a little help from your server's OS.

Conceptually you will use cronjob to run your service from time to time via the command line:

 > * * * * * php -f /path/pro/meu/script.php

On a Windows server, you can do the same thing with Schedule Tasks

Then the part of your code just make the calls to the webservice normally.

    
30.05.2015 / 04:37
2

Instead of creating another webservice, you can use the A trigger service

It is a FREE service where you register and schedule the call of a Url in a predetermined time interval. If you prefer, you can also use the library for PHP . The call schedule would look something like this:

// referencia a library baixada
require_once("/path/to/atriggerphp/ATrigger.php");
// utiliza a chave e o segredo criados ao se cadastrar
ATrigger::init("YOUR_APIKey","YOUR_APISecret");
// a tag identifica qual é tarefa agendada no serviço
$tags = array();
$tags['type']='test';

//agenda a chamada no tempo que quiser: Xminute, Xhour, Xday, Xmonth, Xyear
// a cada 1 hora = 1hour
ATrigger::doCreate("1hour", "http://www.meudominio.com/tarefa?param", $tags);

// para pausar a tarefa
ATrigger::doPause($tags);
    
30.05.2015 / 05:11
1

"Complex" your question in the sense of understanding. I'll give my suggestion for what I understand.

If you want to automate something, think about the way you want it, that is, create a WEBSERVICE, to pull information from another, is the best solution.

In the old company (we work with java and python) when we want to do some of these processes, which do not have human interaction, we use a scheduler of tasks schedule . This way, the server itself already does the whole procedure, according to the time specified by you

If you can, be more specific in what you want to do, and so on. So I think the people can give you a BEM better.

    
30.05.2015 / 03:16