本文整理汇总了PHP中OAuth::validToken方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::validToken方法的具体用法?PHP OAuth::validToken怎么用?PHP OAuth::validToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuth
的用法示例。
在下文中一共展示了OAuth::validToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Error
// All responses of this API are valid JSON
header('Content-Type: application/json');
// Start classes we need to work
$error = new Error($config['application']);
$oauth = new OAuth($config['oauth']);
$ldap = new LDAP($config['ldap']);
try {
$database = new Database($config['database']);
} catch (Exception $e) {
$error->send(500, 'database_unavailable', 'Cannot connect to database', 'Adapt configuration to be able to create a valid database connection');
}
// Validate we have a proper access token
if (!isset($_GET['access_token'])) {
$error->send(401, 'oauth_token_missing', 'Missing OAuth token', 'Client must supply a valid OAuth2 access token with board-level permissions');
}
if (!$oauth->validToken($_SERVER['REQUEST_URI'], $_GET['access_token'])) {
$error->send(403, 'oauth_token_invalid', 'OAuth token invalid', 'Access token is invalid, has expired, or does not have sufficient access privileges');
}
// Setup the LDAP connection
if (!$ldap->connect()) {
$error->send(502, 'ldap_unavailable', 'LDAP server not responding', 'The API cannot connect to the LDAP server');
}
if (!$ldap->login()) {
$error->send(500, 'ldap_login_failure', 'Cannot login to LDAP server', 'The API cannot login to the LDAP server');
}
/*
* API endpoint definition
*/
$app = new \Slim\Slim();
// JSON-encoded data of all current members with passes
$app->get('/users', function () use($ldap, $database) {