在这两个网站上,他们都要求提供令牌秘密和消费者秘密: http: //oauth.googlecode.com/svn/code/javascript/example/signature.html http://developer.netflix.com/resources/OAuthTest#instructions
如何以编程方式设置它们:
public void excecuteSigning(String targetURL){
HttpRequestAdapter requestSig = new HttpRequestAdapter(new HttpGet("http://photos.example.net/photos"));
HttpParameters requestparameters = new HttpParameters();
OAuthMessageSigner signer = new HmacSha1MessageSigner();
requestparameters.put(OAuth.OAUTH_CONSUMER_KEY, "dpf43f3p2l4k3l03");
requestparameters.put(OAuth.OAUTH_TOKEN, "nnch734d00sl2jdk");
requestparameters.put(OAuth.OAUTH_NONCE, "kllo9940pd9333jh");
requestparameters.put(OAuth.OAUTH_TIMESTAMP, "1191242096");
requestparameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
requestparameters.put(OAuth.OAUTH_VERSION, "1.0");
requestparameters.put("size", "original");
requestparameters.put("file", "vacation.jpg");
String OAUTH_SIG = signer.sign(requestSig, requestparameters);
System.out.println(OAUTH_SIG);
}
///上面生成这个签名:rYexRY70p6aDDWw0ox0SwERRK2w=
///下面的代码没有生成正确的签名
requestparameters.put("oauth_consumer_secret", "kd94hf93k423kf44");
requestparameters.put(OAuth.OAUTH_TOKEN_SECRET, "pfkkdhi9sl3r4s00");