How to make webservice run without user interaction?

Asked

Viewed 471 times

2

So guys, I’m looking to create a PHP webservice that will do everything through another webservice (by its API). It will check if you have any message having, it processes and returns an appropriate message.

My question is: How to make this web service run?

It has to run automatically, alone. I don’t know how to do this in PHP.

I know there are more appropriate languages for what I want, but PHP is what I have at the moment.

Some light?

  • Which operating system is using on the server?

3 answers

2

Instead of creating another webservice, you can use the service To Trigger

It’s a service FREE where you register and schedule the call of a Url in a predetermined time interval. If you prefer, you can also use the their library for PHP. Call scheduling 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);

1

Well "complex" this your question in the sense of understanding. I’ll give you my suggestion from what I understand.

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

In the old company (we work with java and python) when we wanted to carry out some process of these, which has no human interaction, we used a task scheduler, in English Schedule . This way, the server itself already does the whole procedure, as specified by you

If you can, be more specific about what you want to do and so on. So I think the staff can give you a much better help.

  • So my idea is to create a service inside a messenger using your API. Then my service will receive the messages, process them and send a message back. API won’t send me anything, my service has to check for messages. There will be no direct user interaction with my service, so nothing to "rip it off", make it work. He has to automatically check for messages and that’s my problem, how to make the code "run alone". I’ll edit the question to make it more "understandable".

  • As I had drawn in my reply, there is a Schedule par to php, as the staff responded below. In your case, this way I told you, it will certainly work.

1


To do what you want PHP will need a "little help" from outside: from your server’s OS.

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

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.