3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'https://www.tiny.com.br/api2/produtos.pesquisa.php'; $token = '6134695a443b60856faf745793258745e3328a33'; $pesquisa = 'xxxxx'; $data = "token=$token&pesquisa=$pesquisa&formato=XML"; enviarREST($url, $data); function enviarREST($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problema com $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problema obtendo retorno de $url, $php_errormsg"); } return $response; }

preferences:
50.65 ms | 402 KiB | 5 Q