Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Pega a URL
- $url = $_GET["url"];
- if(isset($_POST["att"])) {
- $h = ('Content-type: text/json') ;
- unset($_POST["att"]);
- // Caso for requisição long não usar curl
- $params = http_build_query ($_POST);
- echo file_get_contents($url."?".$params) ;
- }
- else
- {
- $h = ('Content-Type: application/json');
- }
- // Fazer a requisição JSON em CURL
- $dados = json_encode($_POST);
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $dados);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- $h,
- 'Content-Length: ' . strlen($dados))
- );
- $result = curl_exec($ch);
- // Arrumar cabeçalho
- header($h);
- // Imprimir
- echo $result;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement