Created
June 23, 2017 20:04
-
-
Save rodrigobravo/209ef3aa43726dff4fa0b813d4871de3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function curlExec($url, $post = NULL, array $header = array(), $username, $password, $accumulator) | |
| { | |
| $url = "http://127.0.0.1:8087/RPC3"; | |
| //Inicia o cURL | |
| $ch = curl_init($url); | |
| //Pede o que retorne o resultado como string | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| //Envio de User e Password | |
| curl_setopt($ch, CURLOPT_USERPWD, "1:1"); | |
| //Envia cabeçalhos (Caso tenha) | |
| if(count($header) > 0) { | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | |
| } | |
| //Envia post (Caso tenha) | |
| if($post !== null) { | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $post); | |
| } | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, Array('Content-Type: application/xml; charset=utf-8')); | |
| //Ignora certificado SSL | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| //Manda executar a requisição | |
| $data = curl_exec($ch); | |
| //Fecha a conexão para economizar recursos do servidor | |
| curl_close($ch); | |
| //Retorna o resultado da requisição | |
| return $data; | |
| } | |
| $post = $_POST['data']; | |
| return($_POST); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment