我试图利用奥乌特进行核查。 我的榜样守则是:
ArrayList <NameValuePair> params = new ArrayList<NameValuePair>();
boolean flag=false;
URL url;
String oauth_nonce="q14F5ApN4Ka5RJGbYgabXwMSZ4BxVrlNGedN9zoFAoi3rc7dpLjIgri1erAAriPu";
String oauth_timestamp="1336069726";
String signatureString =
URLEncoder.encode("device_id=id_here")
+URLEncoder.encode("&device_type=psw_here")
+URLEncoder.encode("&oauth_consumer_key=consumer_key_here...&oauth_nonce=" +
oauth_nonce+
"&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1336069726&oauth_version=1.0");
String percent_encoded_url = URLEncoder.encode("http://www.example.com");
String signatureBaseString = "POST"+
"&"+percent_encoded_url+
"&"+signatureString;
String oauth_signature=URLEncoder.encode(computeHmac(signatureBaseString, "aWAQTWR7VvHapaNhWBCL0VaUdGN2xzN4&"));
String headerValue ="OAuth "+
"oauth_consumer_key=""+"consumer_key_here..."+"","+
"oauth_signature_method="HMAC-SHA1"+"","+
"oauth_signature=""+oauth_signature+"","+
"oauth_timestamp="1336069726"+"","+
"oauth_nonce=""+oauth_nonce+""," +
"oauth_version="1.0"+""";
HttpPost httppost = new HttpPost("http://www.example.com/");
httppost.setHeader("Content-Type","application/x-www-form-urlencoded");
httppost.setHeader("Authorization",headerValue);
HttpEntity httpentity = new UrlEncodedFormEntity(params);
HttpClient httpclient = new DefaultHttpClient(clientConnectionManager, httpparams);
StringBuilder sb = new StringBuilder();
try {
HttpResponse response = httpclient.execute(httppost);
当我发出要求时,总是说Bad Apmat。 我不知道奥乌特。 我对我的错误没有想法。 谁能指导我正确方向?