How to send information via local POST to external server?

Asked

Viewed 88 times

0

I am developing an application that needs to be on a local server and need to send some information to an external server, how should I do?

  • You can give more details ?

  • So friend, my application uses the Arduino and due to this the Arduino must be connected to the server, the application has a login system, if the user forget the password I must send an email with the new password, I tried to send the email locally with Phpmailer but it didn’t work so my idea was to send by POST the information so that the external server can send the email

  • You can create a Webservice on the external server and use it on Arduino.

  • Hmm, thank you very much.

1 answer

0

To post to an external server, use Curl:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,            'http://www.exemplo.com.br');
curl_setopt($ch, CURLOPT_POSTFIELDS,     http_build_query(array('login' => 'abc', 'senha' => '1234')));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST,           true);

$consulta = curl_exec($ch);
curl_close($ch);

Browser other questions tagged

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