function GenSignature($key, $secret, $token, $token_secret, $httpMethod, $endpoint, $params) { require_once "OAuth_TestServer.php"; $test_server = new TestOAuthServer(new MockOAuthDataStore()); $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); $test_server->add_signature_method($hmac_method); //$sig_methods = $test_server->get_signature_methods(); $sig_method = $hmac_method; $test_consumer = new OAuthConsumer($key, $secret, NULL); $test_token = NULL; $test_token = new OAuthToken($token, $token_secret); //$params is the query param array which is required only in the httpMethod is "GET" $params = array(); //set the Query parameters to $params if httpMethod is "GET" $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $httpMethod, $endpoint, $params); $acc_req->sign_request($sig_method, $test_consumer, $test_token); $response = OAuthutil::parseQueryString($acc_req); return $response; }
<?php require_once "../OAuth.php"; require_once "../OAuth_TestServer.php"; /* * Config Section */ $domain = $_SERVER['HTTP_HOST']; $base = "/oauth/example"; $base_url = "http://{$domain}{$base}"; /** * Some default objects */ $test_server = new TestOAuthServer(new MockOAuthDataStore()); $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); $plaintext_method = new OAuthSignatureMethod_PLAINTEXT(); $rsa_method = new TestOAuthSignatureMethod_RSA_SHA1(); $test_server->add_signature_method($hmac_method); $test_server->add_signature_method($plaintext_method); $test_server->add_signature_method($rsa_method); $sig_methods = $test_server->get_signature_methods();