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 de Token PHP de Exemplo
Aplica-se a
Produto: NetSuite 2024.1
Cenário
O cliente está solicitando um código de verificação de token de amostra em PHP.
Solução
O exemplo a seguir fornece informações de verificação de token sem dependências do PHP Toolkit. O exemplo é simplificado com uma solicitação SOAP estática para demonstrar como o Single Sign-On (SSO) de saída funciona com os Web Services. Para uma implementação em sua organização, você precisará de algo para gerar a solicitação SOAP para você.
<?php
//informações do registro SuiteSignOn
$consumer_key = '1odsPu5yva7LN8E7';
$shared_secret = 'samplepw1';
//informações da solicitação
$oauth_token = $_GET[""oauth_token""];
$dc = $_GET[""dc""];
$env = $_GET[""env""];
echo ""<h2>Verificar chamada</h2>"";
$host = discoverUrl( ""ui"", $env, $dc);
$response = validateOauth($oauth_token, $consumer_key, $shared_secret, $host);
if (false === $response )
{
echo ""Chamada de verificação falhou!"";
}
else
{
echo ""Chamada de SSO de saída bem-sucedida"";
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
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!