昨天,我一直在为我和roid子的 app子实施奥阿思。 我在问题之后陷入了问题。 我只想签署一项请求,将其寄给网络服务并收回答复(我认为,这是两条gged脚的办法)。
我下载标语:
- 离职后记分1.2
- 邮局:http4-1.2.1.2
我在我的图书馆铺设道路上添加了jar。
www.un.org/spanish/ecosoc 是否有具体之处,我是否有必要将这些珍珠档案归档,以便它们开展工作?
我感到最麻烦的那部分正在产生签字,并最终签署请求。 推土机不断向HttpPare公墓投掷。
www.un.org/spanish/ecosoc 难道有办法让我有计划地创造基础吗?
难道有人可以把我引向两条gged的奥乌特和甲状腺特例?
我的法典如下:
public void excecuteSigning(String targetURL){
String SOAP_ACTION = "http://amebatv.com/api/authDevice";
System.setProperty("http.keepAlive", "false");
HttpURLConnection _request = null;
DefaultHttpClient httpclient = null;
try{
CONSUMER_SECRET = app_pref.getString("consumerSecret", "");
CONSUMER_KEY = app_pref.getString("consumerKey", "");
String oaut_token = app_pref.getString("accessToken", "");
String tokenSecret = app_pref.getString("tokenSecret", "");
String deviceId = deviceInfo.getSerial();
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer (CONSUMER_KEY,CONSUMER_SECRET);
consumer.setTokenWithSecret(oaut_token, tokenSecret);
//HttpRequest request;
HttpParameters requestParameters = new HttpParameters();
requestParameters.put("file", "vacation.jpg");
requestParameters.put(OAuth.OAUTH_CONSUMER_KEY, "dpf43f3p2l4k3l03");
requestParameters.put(OAuth.OAUTH_NONCE, "kllo9940pd9333jh");
requestParameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
requestParameters.put(OAuth.OAUTH_TIMESTAMP, "1191242096");
requestParameters.put(OAuth.OAUTH_TOKEN, "nnch734d00sl2jdk");
requestParameters.put(OAuth.OAUTH_VERSION, "1.0");
requestParameters.put("size", "original");
HttpPost request = new HttpPost(targetURL);
SignatureBaseString baseString = new SignatureBaseString((HttpRequest) request, requestParameters);
String base = baseString.generate();
System.out.println(":"+base);
System.out.println(computeHmac(base,"kd94hf93k423kf44&pfkkdhi9sl3r4s00"));
httpclient = new DefaultHttpClient();
ContentProducer cp = new ContentProducer() {
public void writeTo(OutputStream outstream) throws IOException {
Writer writer = new OutputStreamWriter(outstream, "UTF-8");
writeXml(writer);
}
};
HttpParameters params = new HttpParameters();
HttpEntity entity = new EntityTemplate(cp);
HttpPost request = new HttpPost(targetURL);
request.addHeader("Authorization",AUTH_HEADER);
request.addHeader("Content-Type", "text/xml; charset=utf-8");
//request.addHeader("Content-Length",""+soapXML.getBytes().length);
request.addHeader("SOAPAction",SOAP_ACTION);
request.setEntity(entity);
// sign the request
consumer.sign(request);
// send the request
//request.connect();
HttpResponse response = httpclient.execute(request);
//get response
//StringBuffer response = new StringBuffer();
InputStream instream = null;
BufferedReader br = null;
try{
int respcode = response.getStatusLine().getStatusCode();
Log.i("Server Response", ""+respcode);
//get XML from InputStream
if(respcode>= 200){
instream = response.getEntity().getContent();
client.buildDoc(instream);
}
else{
Log.i("Server Response", ""+respcode);
//instream = request.getErrorStream();
}
}catch(Exception e){
Log.i("SPLASH","Unable to create connection stream");
e.printStackTrace();
}
finally {
if(instream != null) {
Log.i("SPLASH","Disconnecting stream");
instream.close();
}
}
*/
}
catch(Exception e){
Log.i("SPLASH","Unable to create connection");
e.printStackTrace();
}finally {
if(httpclient != null) {
Log.i("SPLASH","Disconnecting");
httpclient.getConnectionManager().shutdown();
}
}
}
/*
* Method:computeHmac()
* @params: String, String
* return: String
*/
public String computeHmac(String baseString, String key)
throws NoSuchAlgorithmException,
InvalidKeyException,
IllegalStateException,
UnsupportedEncodingException
{
Mac mac = Mac.getInstance("HmacSHA1");
SecretKeySpec secret = new SecretKeySpec(key.getBytes(), mac.getAlgorithm());
mac.init(secret);
byte[] digest = mac.doFinal(baseString.getBytes());
return Base64.encodeToString(digest,Base64.URL_SAFE);
}