Discussões

Please note that on Friday, March 20, 2026, at 8:00 PM Pacific time, our Case Management System will undergo a scheduled maintenance for approximately 4 hours. During this time, case creation via SuiteAnswers will be unavailable and inbound calls will be routed to Customer Service.

Código de verificação do Token PHP de amostra

editado Feb 2, 2024 7:07PM Dentro SuiteCloud / Personalização

Aplica-se a

Produto: NetSuite 2023.1



Cenário

O cliente está solicitando um código de verificação de token PHP de amostra.



Solução

O exemplo a seguir fornece informações de verificação de token sem dependências no PHP Toolkit. O exemplo é simplificado com uma solicitação SOAP estática para demonstrar como o SSO (Single Sign-On) de saída funciona com Serviços da web. Para uma implementação na sua organização, você precisará de algo para gerar a solicitação SOAP para você. 

 

<?php
 
//information from SuiteSignOn record
$consumer_key = '1odsPu5yva7LN8E7';
$shared_secret = 'samplepw1';
 
//information from request
$oauth_token = $_GET["oauth_token"];
$dc = $_GET["dc"];
$env = $_GET["env"];
 
echo "<h2>Verify call</h2>";
$host = discoverUrl( "ui", $env, $dc);
$response = validateOauth($oauth_token, $consumer_key, $shared_secret, $host);
if (false === $response )
{‌
    echo "Verify call failed!";
}
else
{‌
    echo "Outbound SSO call Succeed";
    echo "<pre>". htmlentities($response) ."</pre>";
 
    $host = discoverUrl( "webservices", $env, $dc);
    for ($i = 1; $i < 6; $i++){‌
        echo "<h2>$i. WS call</h2>";
        $header = makeOAuthHeaderString($oauth_token, $consumer_key, $shared_secret);
        $wsresponse = sendWsRequest( $host, -5, $header );
        echo htmlentities($wsresponse);
    }
}
 
function validateOauth( $token, $consumer_key, $shared_secret, $host )
{‌
    $method = "GET";
    $protocol = parse_url($host)['scheme'];
 
    $context = stream_context_create(array('http'=>array('header'=> makeOAuthHeaderString($token, $consumer_key, $shared_secret) . " \r\n")));
    stream_context_set_option($context, $protocol, "method", $method);
    stream_context_set_option($context, $protocol, "timeout", 300);
 
    $verifyResult=file_get_contents($host . '/app/common/integration/ssoapplistener.nl', false, $context);
 
    return !$verifyResult?false:$verifyResult;
}
 
function makeOAuthHeaderString($token, $consumer_key, $shared_secret)
{‌
    $timestamp=time();
    $nonce=mt_rand();
 
    $returnString

Olá, bem-vind@!

Faça login

Para ver todos os detalhes, faça o login.

Cadastre-se

Não tem uma conta? Clique aqui para começar!

Ranking

Gênio da Comunidade

1º Trimestre (Jan-Mar 2026)

Líderes desta semana

Líderes deste mês

Líderes de todos os tempos