<?php
require_once 'oauthLibrary/OAuthServer.php';
session_start();
// Add a header indicating this is an OAuth server
header('X-XRDS-Location: http://' . $_SERVER['SERVER_NAME'] . '/services.xrds.php');
// Connect to database
$db = new PDO('mysql:host=localhost;dbname=oauthdb', 'root', '');
// Create a new instance of OAuthStore and OAuthServer
$store = OAuthStore::instance('PDO', array('conn' => $db));
$server = new OAuthServer();
OAuthRequestLogger::enableLogging($store);
?>
<?php
session_start();
define("PATH_URL_CLIENT", "/oauth/client");
define("PATH_URL_SERVER", "/oauth/server");
define("REQUEST_TOKEN", "REQUEST_TOKENsdsdfw324ft3f3f34r34");
define("ACCESS_TOKEN", "ACCESS_TOKENkdfj33jdl23");
define("OAUTH_TOKEN", "OAUTH_TOKENdfs34fre45u67jyu");
define("OAUTH_VERIFIER", "OAUTH_VERIFIERslsjlf32j3jlfj");
require './lib/OAuthClient.php';
$client = new OAuthClient('8179e89ff6558cce5628e60643a7124c053cfc204', 'f46dfa522890df25e71ccd9db463a708');
function getServerUrl() {
return "http://".$_SERVER["HTTP_HOST"].PATH_URL_SERVER;
}
function getClientUrl() {
return "http://".$_SERVER["HTTP_HOST"].PATH_URL_CLIENT;
}
function toSession($key, $value) {
$_SESSION[$key] = is_null($value) ? $value : serialize($value);
}
function fromSession($key) {
if(isset($_SESSION[$key]) && !is_null($_SESSION[$key])) {
return unserialize($_SESSION[$key]);
}
return null;
}
?>
No comments:
Post a Comment