3 /** @package verysimple::Authentication */
5 require_once "oauth/OAuthStore.php";
6 require_once "oauth/OAuthRequester.php";
7 require_once "verysimple/String/VerySimpleStringUtil.php";
10 * A set of utility functions for working with OAuth
12 * @package verysimple::String
13 * @author Jason Hinkle
14 * @copyright 1997-2012 VerySimple, Inc.
15 * @license http://www.gnu.org/licenses/lgpl.html LGPL
21 * Given a URL return an OAuth signed URL.
22 * This will handle creating a timestamp and nonce
26 * @param string $method
27 * request method GET, POST, PUT, DELETE
30 * @param string $secret
32 * @param array $params
33 * querystring or post parameters
35 * the body contents of the request
36 * @param string $signature_method
37 * method used for signature (default = 'HMAC_SHA1')
39 public static function SignUrl($url, $method, $key, $secret, $params = null, $body = null, $signature_method = 'HMAC_SHA1')
42 'consumer_key' => $key,
43 'consumer_secret' => $secret
45 $params = $params ?
$params : array ();
47 OAuthStore
::instance("2Leg", $options);
49 // Obtain a request object for the request we want to make
50 $request = new OAuthRequester($url, $method, $params, $body);
52 $sig = $request->sign($key, null, '');
54 $data = $request->signatureBaseString();
56 $url = substr(urldecode($data . '&oauth_signature=' . $request->calculateDataSignature($data, $secret, '', $signature_method)), strlen($method) +
1);
58 $url = VerySimpleStringUtil
::ReplaceFirst('&', '?', $url);