private function getOAuthHeader($location, $request) { try { $oauth = new OAuthSimple($this->getAccountId(), $this->getSharedKey()); $oauth->setAction("POST"); $oauth->genBodyHash($request); $parse = parse_url($location); $port = (isset($parse["port"]) and ($parse["port"] == '80' or $parse["port"] == '443')) ? '' : !isset($parse["port"]) ? '' : ':' . $parse["port"]; if (!is_null($this->language)) { $oauth->setParameters(array('lang' => $this->language)); } $oauth->setPath($parse["scheme"] . '://' . $parse["host"] . $port . $parse["path"]); $header_string = $oauth->getHeaderString(); $oauth->reset(); } catch (Exception $e) { throw new TurnitinSDKException('oautherror', $e->getMessage(), $this->getLogPath()); } return $header_string; }
$apiKey $sharedSecret $accessToken $tokenSecret */ // Some sample argument values // You can pass in arguments either as a string of URL characters: $argumentsAsString = "term=mac%20and+me&expand=formats,synopsis&max_results=1"; // or a hash: $argumentsAsObject = array('term' => 'the prisoner', 'expand' => 'formats,synopsis', 'max_results' => '1', 'v' => '2.0', 'output' => 'json'); $path = "http://api.netflix.com/catalog/titles"; # Test 1 ==== $oauth = new OAuthSimple($apiKey, $sharedSecret); $oauth->setParameters($argumentsAsString); $oauth->setPath($path); $sample1Results = $oauth->sign(); # Test 2 ===== $oauth = null; $oauth = new OAuthSimple($apiKey, $sharedSecret); $sample2Results = $oauth->sign(array('action' => 'GET', 'path' => $path, 'parameters' => $argumentsAsObject)); # Test 3 ====== $oauth = new OAuthSimple(); $sample3Results = $oauth->sign(array('path' => 'http://api.netflix.com/catalog/people', 'parameters' => array('term' => 'Harrison Ford', 'max_results' => '5'), 'signatures' => array('consumer_key' => $apiKey, 'shared_secret' => $sharedSecret, 'access_token' => $accessToken, 'access_secret' => $tokenSecret))); ?> <html> <head> <title>Test Document</title> </head> <body> <h1>Test Document</h1>