How to fill input field and submit form with cURL?

0

How do I fill out the input and submit of form for this site link using cURL?

I want to use the video chat system of this site in my project, it is very simple to create a new chat room, but in my project I need this to be done automatically by the system.

    
asked by anonymous 29.03.2017 / 18:44

1 answer

1

I recommend using their official API which is JavaScript , add in your HTML this (it has to run under the HTTP or HTTPS protocol, file may not support):

<script src="//developer.appear.in/scripts/appearin-sdk.0.0.4.min.js"></script>

And then call this:

var AppearIn = window.AppearIn || require('appearin-sdk');
var appearin = new AppearIn();

// verifica se o navegador usa WebRTC
var isWebRtcCompatible = appearin.isWebRtcCompatible();

if (isWebRtcCompatible) {
    //Cria uma sala
    appearin.getRandomRoomName().then(function (roomName) {
        //Após iniciar a sala
    });
}

If you have a specific room do so:

<iframe id="meu-iframe"></iframe>

And in JavaScript this:

var minhaSala = "rodrigo-fontes";
appearin.addRoomToElementById("meu-iframe", minhaSala);

But if you still need PHP for some reason, like creating rooms dynamically, using curl is relatively simple, apparently you have to use HTTPS, so do so:

$nomedasala = 'nome da sala';

$url = 'https://appear.in/' . urlencode($nomedasala);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

//Define um User-agent
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0');

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

//Retorna a resposta
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Resposta
$data = curl_exec($ch);

If you give an error message about SSL or HTTPS then it is because your server is disconnected, you need to enable the SSL module, here's how to do it link

But if you can not at all, you can simply turn off the check (which I do not recommend):

//Desliga
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    
29.03.2017 / 18:54