Log in

No account? Create an account
Helloo - LiveJournal Client Discussions — LiveJournal [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Helloo [Apr. 19th, 2002|11:46 am]
LiveJournal Client Discussions


Hi everyone! Ive just joined this group as im getting into a little Java programming and have been doing a little work on a client. Im not quite there yet though (in fact its all going horribly wrong... damn post stuff...) but Id still like to contribute to the whole LJ scene, so im offering everyone whose developing LJ clients or programs free web hosting accounts on my server.

You'll get a few hundred megs space, basic shell access and PHP4 and Perl scripting support. Check out the details of the servers at www.BeUnleashed.com and mail me at wiggi@beunleashed.com and ill set you up :)

Hope this is useful to some of ya :)

From: t0sh
2002-04-19 04:09 am (UTC)
Hey Wigs :-)

If you need help on any of the POST stuff give us a shout. I've got a half implemented Java client lying around here... somewhere...
(Reply) (Thread)
[User Picture]From: wiggi
2002-04-19 06:20 am (UTC)

Java LJ client

cool, cheers. I was playing around with all the network Java classes and madea little prog to grab data from a web page and got it working through our god forsaken proxy. Then I started looking at ways to do POST stuff and thought the best way was to create buffered input/output streams streams to the server and send/recieve data through them. When I did ths i got it working, but the stream which sent data didn`t seem to do its job possibly, and i think it only did the first line (even though i was flushing it and all). The stream which got data from the site worked fine and returned the correct stuff, but just told me that the commands i was sending made no sense. I blamed it all on the proxy and gave up for a while.

ill proberbly start it again in a few weeks when ive got all my courseork out the way.
(Reply) (Parent) (Thread)
From: t0sh
2002-04-19 10:53 am (UTC)

Re: Java LJ client

Check out Sockets and ServerSockets... you open streams with them similar to filestreams and can just print() and readLine() to and from the server. Nice and easy :-)
(Reply) (Parent) (Thread)
[User Picture]From: wiggi
2002-04-19 11:59 am (UTC)

Re: Java LJ client

I was using

Socket tSocket = new Socket("www.livejournal.com", 80);

and i think it was working, then I created a DataInputStream and DataOutputStream around tSocket.getInputStream() etc. and i think I created a Buffered Reader around the input stream for some reason. I haven't treid it in ages as I have to do it from the labs... I then used the writeChar method for the streams to send the POST command over but that was where it all went pear shaped :(
(Reply) (Parent) (Thread)
[User Picture]From: poisonkitty
2002-05-04 01:38 am (UTC)

Re: Java LJ client

try some code such as the following:

public HashMap postLJRequest(URL url, HashMap params) throws Exception
	System.out.println("DEBUG: url: " + url);
	System.out.println("DEBUG: params: " + params);
	URLConnection urlConn;
	DataOutputStream printout;
	BufferedReader input;
	urlConn = url.openConnection();
	// Let the run-time system (RTS) know that we want input.
	// Let the RTS know that we want to do output.
	// No caching, we want the real thing.
	// Specify the content type.

	// Send POST output.
	printout = new DataOutputStream(urlConn.getOutputStream());
	String content = "";
	Iterator iter = params.keySet().iterator();
		String key = (String) iter.next();
		String val = (String) params.get(key);
		content += key + "=" + URLEncoder.encode(val);
			content += "&";

	// Get response data.
	input = new BufferedReader(
		new InputStreamReader(urlConn.getInputStream()));
	String str;
	HashMap reply = new HashMap();
	String key = null;
	String val = null;
	int count = 1;
	while (null != ((str = input.readLine())))
			// this is a key
			key = str;
			System.out.println("key: " + str);
			// this is a value
			val = str;
			System.out.println("val: " + str);

		if(key != null && val != null)
			reply.put(key, val);
			key = null;
			val = null;

	return reply;


A good test for such a method might be:

public static void main(String args[])
	String username = "test";
	String password = "test";
	String hostname = "www.livejournal.com";
	HashMap params = new HashMap();
	params.put("mode", "getfriends");
	params.put("user", username);
	params.put("password", password);
	URL url = new URL("http://" + hostname + "/interface/flat");
	response = LJUtils.postLJRequest(url, params);
	if (!"OK".equals(response.get("success")))
		// error!

	int friendCount = Integer.parseInt((String) response.get("friend_count"));
	for (int i = 1; i <= friendCount; i++)
		String username = (String) response.get("friend_" + i + "_user");
		String name = (String) response.get("friend_" + i + "_name");
		String bgColor = (String) response.get("friend_" + i + "_bg");
		String fgColor = (String) response.get("friend_" + i + "_fg");
		System.out.println(username + name + bgColor + fgColor));
(Reply) (Parent) (Thread)
[User Picture]From: poisonkitty
2002-05-04 04:54 pm (UTC)

Re: Java LJ client

I left out a little method that I call from that code:
public static boolean isOdd(int num)
	if( ((num / 2) * 2) == num)
		return false;
	return true;

(Reply) (Parent) (Thread)
[User Picture]From: wiggi
2002-05-06 04:05 am (UTC)

Re: Java LJ client

cheers, ill have a play later :)
(Reply) (Parent) (Thread)
[User Picture]From: xb95
2002-04-19 11:22 am (UTC)
Hmm. Where is the server physically located? It seems to respond fast enough while I'm here at work, but I don't have access to my happy fun ping and traceroute utilities out here. (Though it'd probably be easy enough to find one online, heh.)

I'm interested, yes. I develop LochJournal (lochjournal) in my spare time. (Which, uh, thanks to Dark Age of Camelot isn't much right now. *cough*)
(Reply) (Thread)
[User Picture]From: wiggi
2002-04-19 11:53 am (UTC)
The server is in a datacentre in central England and is backed by a 120MBit net connection. I wont do anything silly like bandwidth restrictions and I don't mind people putting their personnal sites on, as long as your all supporting or contrbuting to LJ in some way :)

Ill give you a subdomain of beunleashed.com unless you have your own domain name that you want to use, or you can have one of your chosing for £10 p/a (I have to charge as I have to cover naming fees, sorry).

Anywho, your welcome to it if you like, just drop me a mail some time :~)
(Reply) (Parent) (Thread)