$serviceType = IntuitServicesType::QBO;
// Get App Config
$realmId = ConfigurationManager::AppSettings('RealmID');
if (!$realmId) {
    exit("Please add realm to App.Config before running this sample.\n");
}
// Prep Service Context
$requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'), ConfigurationManager::AppSettings('AccessTokenSecret'), ConfigurationManager::AppSettings('ConsumerKey'), ConfigurationManager::AppSettings('ConsumerSecret'));
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
if (!$serviceContext) {
    exit("Problem while initializing ServiceContext.\n");
}
// Prep Platform Services
$platformService = new PlatformService($serviceContext);
// Get App Menu HTML
$Respxml = $platformService->Reconnect();
if ($Respxml->ErrorCode != '0') {
    echo "Error! Reconnection failed..";
    if ($Respxml->ErrorCode == '270') {
        echo "OAuth Token Rejected! <br />";
    } else {
        if ($Respxml->ErrorCode == '212') {
            echo "Token Refresh Window Out of Bounds! <br />";
        } else {
            if ($Respxml->ErrorCode == '24') {
                echo "Invalid App Token! <br />";
            }
        }
    }
} else {
    echo "Reconnect successful! Please update the app.config file with the new oAuth tokens.<br />";