我试图将桌面应用程序连接起来,我是同D.icio.us api @ Delicious API/a,简单地向他们提供我的用户名和密码,并请他们把书记上张贴在我的简介上。
我面临的问题是,我不理解在我开放联系时如何派我的 log。
我怎么做呢?
我试图将桌面应用程序连接起来,我是同D.icio.us api @ Delicious API/a,简单地向他们提供我的用户名和密码,并请他们把书记上张贴在我的简介上。
我面临的问题是,我不理解在我开放联系时如何派我的 log。
我怎么做呢?
查阅网站:
所有文件/文件都需要https request和HTTP-Auth。
HTTP-Auth
is header used in basic authentication.
In Java, you can simply put your credentials in the URL:
http://user:pass@www.example.com/
您可以核实,该编码是使用
HttpUrlConnection允许你履行http://blog.taragana.com/index.php/archive/java-tip-basic-authentication-with-httpurllinkion/"rel=“nofollow noretinger”>basic accreditation。 较强大的HttpClient libraru为你提供了more Solutions(Basic, Digest, and NTLM- 我认为需要)。
如果你确实需要吉大港山区基本居住条件,你可以像现在这样形成:
http://user:password@www.website.com
最新资料:
利用所提供的实例,这项工作应当:
https://user:password@api.del.icio.us/v1/posts/add&url=http://www.google.com&description=awesome
HttpURLConnection确实允许你做基本的 au,但如果你希望更复杂的认证能够工作,请Apache HTTPClient。 它可以无缝地通过http://www.un.org/www.un.org/french/ga/president
答案是:
public String reloadTomcatWebApplication(String user, String pwd, String urlWithParameters, boolean returnResponse){
URL url = null;
try {
url = new URL(urlWithParameters);
} catch (MalformedURLException e) {
System.out.println("MalformedUrlException: " + e.getMessage());
e.printStackTrace();
return "-1";
}
URLConnection uc = null;
try {
uc = url.openConnection();
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
e.printStackTrace();
return "-12";
}
String userpass = user + ":" + pwd;
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
uc.setRequestProperty ("Authorization", basicAuth);
InputStream is = null;
try {
is = uc.getInputStream();
} catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
e.printStackTrace();
return "-13";
}
if(returnResponse){
BufferedReader buffReader = new BufferedReader(new InputStreamReader(is));
StringBuffer response = new StringBuffer();
String line = null;
try {
line = buffReader.readLine();
} catch (IOException e) {
e.printStackTrace();
return "-1";
}
while (line != null) {
response.append(line);
response.append(
);
try {
line = buffReader.readLine();
} catch (IOException e) {
System.out.println(" IOException: " + e.getMessage());
e.printStackTrace();
return "-14";
}
}
try {
buffReader.close();
} catch (IOException e) {
e.printStackTrace();
return "-15";
}
System.out.println("Response: " + response.toString());
return response.toString();
}
return "0";
}
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...