(HTTP)
POST /token HTTP/1.1
Host: sandbox.pigpag.com.br
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Host: sandbox.pigpag.com.br
cache-control: no-cache
username=SANDBOXPIGPAG&password=8E765DB0-9C1C-44D0-85AB-8FD0B2E7D7CD&grant_type=password
(PHP – cURL)
<?php
$curl = curl_init(); curl_setopt_array($curl, array(
CURLOPT_URL => “https://sandbox.pigpag.com.br/token”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION =>
CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “username=SANDBOXPIGPAG&password=8E765DB0-9C1C-44D0-85AB-8FD0B2E7D7CD&grant_type=password”,
CURLOPT_HTTPHEADER => array(“cache-control: no-cache”),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo “cURL Error #:” . $err;
} else {
echo $response; }
?>
(C# – RestSharp)
var client = new RestClient(“https://sandbox.pigpag.com.br/token”);
var request = new RestRequest(Method.POST);
request.AddHeader(“Cache-Control”, “no-cache”);
request.AddHeader(“Content-Type”, “application/x-www-form-urlencoded”);
request.AddParameter(“undefined”,
“username=SANDBOXPIGPAG&password=8E765DB0-9C1C-44D0-85AB-8FD0B2E7D7CD&grant_type=password”, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Exemplo de resposta:
{ “access_token”: “FGshaj7Cz8YO6SdSaEZipOJK7oXfTwYF2tmoj73sALP97oABULv5xsuYIUwdTA-92l5pELVesqfO89VYh7PWelnuIHH_FWuGmypk2JHoNjS5yu_Ar72XxW1ALweJ7oH12FTe3NDad92DFol1JdysTIhuk5WyZMB5Cf7h3I8hT68XBy5c7TSy-6om8tQSLhukHr0c4Hus0szbrQ0DJVJ–F8EofvPA8kC7LsHp7dgd_qhEJAmMgfuwKsoqMlVMjol”, “token_type”: “bearer”, “expires_in”: 3599}