卷曲相当于JAVA [英] cURL equivalent in JAVA

查看:140
本文介绍了卷曲相当于JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我任务是一个开源的 JAVA 应用程序编写验证组件。我们有一个使用 HTTPS 的内部认证部件。我有一些例如 PHP code,它访问小部件,它使用卷曲来办理过户。

I am tasked with writing an authentication component for an open source JAVA app. We have an in-house authentication widget that uses https. I have some example php code that accesses the widget which uses cURL to handle the transfer.

我的问题是,是否有卷曲 JAVA ,或一个端口更好,什么基地包将让我足够接近处理任务?

My question is whether or not there is a port of cURL to JAVA, or better yet, what base package will get me close enough to handle the task?

更新

这是概括地说,在code,我想在JAVA中复制:

This is in a nutshell, the code I would like to replicate in JAVA:

$cp = curl_init();
$my_url = "https://" . AUTH_SERVER . "/auth/authenticate.asp?pt1=$uname&pt2=$pass&pt4=full";
curl_setopt($cp, CURLOPT_URL, $my_url);
curl_setopt($cp, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($cp);
curl_close($cp);

希思,我认为你是在正确的轨道上,我想我要去最终使用HttpsURLConnection的,然后挑选出我从响应所需要的。

Heath, I think you're on the right track, I think I'm going to end up using HttpsURLConnection and then picking out what I need from the response.

推荐答案

异常处理省略:

HttpURLConnection con = (HttpURLConnection) new URL("https://www.example.com").openConnection();
con.setRequestMethod("POST");
con.getOutputStream().write("LOGIN".getBytes("UTF-8"));
con.getInputStream();

这篇关于卷曲相当于JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆