P
PugetSoundSylvia
Hello all,
I've been banging my head against the wall trying to get some code
working in Perl. I'm assuming it will need to use the LWP module, and
I've gotten some basic things working with LWP, but not the whole
thing.
I have samples in Java, shown below. I'm stuck at the
setRequestProperty. What's the equivalent in Perl, using LWP?
I would SO appreciate any pointers on this on.
Sylvia
public TestLogin() throws IOException {
if (Debug) System.out.println("TestLogin: Logging in...");
/** Send the HTTPS request */
URL url_login = new URL(Profile.Protocol+"://"+ /** i.e,
either http or https */
Profile.Hostname+"/api/login.php"+ /** the
actual website, like TestSite.org */
"?name="+Profile.UserID+ /** site
specific parameter */
"&pass="+Profile.Password+ /** site
specific parameter */
"&service_type="+Profile.ServiceType); /** site
specific parameter */
URLConnection urlcon_login = url_login.openConnection();
String auth = Profile.FWUser+":"+Profile.FWPassword;
urlcon_login.setRequestProperty("Authorization", "Basic "+
Base64.encode(auth.getBytes()));
/** Get the HTML response and parse it */
BufferedReader inbuf_login;
inbuf_login = new BufferedReader(
new InputStreamReader(urlcon_login.getInputStream()));
if (inbuf_login != null) parse(inbuf_login);
inbuf_login.close();
if (Debug) System.out.println("TestLogin: Login completed
(Session ID = " + Profile.SessionID+")");
}
I've been banging my head against the wall trying to get some code
working in Perl. I'm assuming it will need to use the LWP module, and
I've gotten some basic things working with LWP, but not the whole
thing.
I have samples in Java, shown below. I'm stuck at the
setRequestProperty. What's the equivalent in Perl, using LWP?
I would SO appreciate any pointers on this on.
Sylvia
public TestLogin() throws IOException {
if (Debug) System.out.println("TestLogin: Logging in...");
/** Send the HTTPS request */
URL url_login = new URL(Profile.Protocol+"://"+ /** i.e,
either http or https */
Profile.Hostname+"/api/login.php"+ /** the
actual website, like TestSite.org */
"?name="+Profile.UserID+ /** site
specific parameter */
"&pass="+Profile.Password+ /** site
specific parameter */
"&service_type="+Profile.ServiceType); /** site
specific parameter */
URLConnection urlcon_login = url_login.openConnection();
String auth = Profile.FWUser+":"+Profile.FWPassword;
urlcon_login.setRequestProperty("Authorization", "Basic "+
Base64.encode(auth.getBytes()));
/** Get the HTML response and parse it */
BufferedReader inbuf_login;
inbuf_login = new BufferedReader(
new InputStreamReader(urlcon_login.getInputStream()));
if (inbuf_login != null) parse(inbuf_login);
inbuf_login.close();
if (Debug) System.out.println("TestLogin: Login completed
(Session ID = " + Profile.SessionID+")");
}