Beispiel #1
0
 public function genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint)
 {
     $authServer = new OAuthServer_WDM(new MockOAuthDataStore_WDM());
     $hmac_method = new OAuthSignatureMethod_WDM_HMAC_SHA1();
     $authServer->add_signature_method($hmac_method);
     $sig_method = $hmac_method;
     $authConsumer = new OAuthConsumer_WDM($key, $secret, NULL);
     $authToken = NULL;
     $authToken = new OAuthToken_WDM($token, $tokenSecret);
     //$params is the query param array which is required only in the httpMethod is "GET"
     $params = array();
     //TODO: set the Query parameters to $params if httpMethod is "GET"
     $acc_req = OAuthRequest_WDM::from_consumer_and_token($authConsumer, $authToken, $httpMethod, $endpoint, $params);
     $acc_req->sign_request($sig_method, $authConsumer, $authToken);
     return OAuthutil::parseQueryString($acc_req);
 }
Beispiel #2
0
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;
}