Skip to content

Instantly share code, notes, and snippets.

View jjcodes78's full-sized avatar
🎯
Focusing

Jorge Gonçalves Junior jjcodes78

🎯
Focusing
View GitHub Profile
@jjcodes78
jjcodes78 / index.php
Last active June 23, 2017 04:29
Dinamicamente envia um valor via POST para o PHP renderizar HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<?php
header("Content-type: text/html");
//
// Run composer with a PHP script in browser
//
// http://stackoverflow.com/questions/17219436/run-composer-with-a-php-script-in-browser
error_reporting(E_ALL);
ini_set('display_errors', 1);
<?php
namespace App\Http\Middleware;
class HandleCorsMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
<?php
namespace App\Http\Controllers;
use SoapClient;
class SoapController extends Controller
{
public function show()
{
// JJSQUADY (Jorge Alberto Junior)
// Abril/2017
// -------------------------------------------------------------------------------------------------------------------------
// Insira este código dentro de uma function
// Se quiser passar o CNES via parâmetro basta comentar o $cnesEstabelecimento e usar essa variável como argumento da função
// não esqueça de importar a classe WsseAuthHeader
$client = new \SoapClient('https://servicos.saude.gov.br/cnes/EstabelecimentoSaudeService/v1r0?wsdl');
$client->__setSoapHeaders(new WsseAuthHeader('CNES.PUBLICO', 'cnes#2015public'));
namespace SoapAuth
use SoapHeader;
use stdClass;
use SoapVar;
class WsseAuthHeader extends SoapHeader {
private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
// Não é obrigatório - It's not required
function getCooperativas($table)
{
$coopTable = $table->nextSibling();
//percorre até a próxima tabela
do
{
$coopTable = $coopTable->nextSibling();
} while($coopTable->tag != "table");
// metodo pra obter os dados do estabelecimento
function getIdentificacao($table)
{
$table = $table->nextSibling();
$identificacao = [];
foreach ($table->children() as $tr) {
// monta as $keys de origem de dados
$keys = [
foreach ($tables as $table)
{
// $table->children(0) = primeiro TR
// $table->children(0)->children(0) - primeiro TD
if ($table->children(0)->children(0) != null)
{
// monta o array com as chaves para encontrar as tabelas
// o nome do indice atrelado aos dados obtidos
// e a função que é chamada para obter os dados de cada seção
//----------------------------------------------------------------
<?php
/**
* Created by PhpStorm.
* User: Jorge
* Date: 27/03/2017
* Time: 13:31
*/
require 'vendor/autoload.php';