22bf706c2fe9dec81375b0de11b28ce1f5090cbc
[WP-Plugins/glm-member-db.git] /
1 <?php
2 namespace PayPal\Auth\Oauth;
3 //PayPal specific modification
4 //Method to be called for generating signature
5
6 class AuthSignature {
7
8         public function genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint) {
9
10                 $authServer = new OAuthServer(new MockOAuthDataStore());
11                 $hmac_method = new OAuthSignatureMethodHmacSha1();
12                 $authServer->add_signature_method($hmac_method);
13
14                 $sig_method = $hmac_method;
15                 $authConsumer = new OAuthConsumer($key, $secret, NULL);
16                 $authToken = NULL;
17                 $authToken = new OAuthToken($token, $tokenSecret);
18
19                 //$params is the query param array which is required only in the httpMethod is "GET"
20                 $params = array();
21                 //TODO: set the Query parameters to $params if httpMethod is "GET"
22
23                 $acc_req = OAuthRequest::from_consumer_and_token($authConsumer, $authToken, $httpMethod, $endpoint, $params);
24                 $acc_req->sign_request($sig_method,$authConsumer, $authToken);
25                 return  OAuthutil::parseQueryString($acc_req);
26         }
27         
28         public static function generateFullAuthString($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint) {
29                 $authSignature = new AuthSignature();
30                 $response = $authSignature->genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint);
31                 return "token=" . $token . 
32                            ",signature=" . $response['oauth_signature'] .
33                        ",timestamp=" . $response['oauth_timestamp'];            
34         }
35         
36 }
37 ?>