AT這兩個網站,他們要求令牌祕密和消費者的祕密: http://oauth.googlecode.com/svn/code/javascript/example/signature.html http://developer.netflix.com/resources/OAuthTest#instructions如何在OAuth中設置令牌機密和使用者密碼?
如何設置他們編程:
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");
上面生成這個簽名:rYexRY70p6aDDWw0ox0SwERRK2w = – Fabii 2012-04-16 19:48:27
沒有OAuth.OAUTH_CONSUMER_SECRET參數,我會如何添加它? – Fabii 2012-04-16 19:49:39