Discussões
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Keep an eye out for upcoming NetSuite events, including meetups, workshops, and webinars. These sessions are a great way to connect with peers, learn from experts, and stay current on the latest NetSuite updates and best practices. Registration links are provided in each event.
Código de verificação do Token PHP de amostra
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
Rotulado:
0
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!