(Perl) SugarCRM Logout
Demonstrates how to logout of a session.
use chilkat();
$rest = chilkat::CkRest->new();
$success = $rest->Connect("your.site.domain",443,1,1);
if ($success != 1) {
print $rest->lastErrorText() . "\r\n";
exit;
}
$rest->AddHeader("Cache-Control","no-cache");
$rest->AddHeader("OAuth-Token","<access_token>");
$sbReq = chilkat::CkStringBuilder->new();
$sbJson = chilkat::CkStringBuilder->new();
$success = $rest->FullRequestSb("POST","/rest/v10/oauth2/logout",$sbReq,$sbJson);
if ($success != 1) {
print $rest->lastErrorText() . "\r\n";
exit;
}
if ($rest->get_ResponseStatusCode() != 200) {
print "Received error response code: " . $rest->get_ResponseStatusCode() . "\r\n";
print "Response body:" . "\r\n";
print $sbJson->getAsString() . "\r\n";
exit;
}
$json = chilkat::CkJsonObject->new();
$json->LoadSb($sbJson);
# The following code parses the JSON response.
# A sample JSON response is shown below the sample code.
$success = $json->BoolOf("success");
# A sample JSON response body that is parsed by the above code:
# {
# "success": true
# }
print "Example Completed." . "\r\n";
|