I'm trying to connect to Facebook using Java Sockets and I get a Http: Bad Request Error.

The hostname I'm using is "facebook.com"

and for the GET request, I have used the following lines.

out.write("GET / HTTP/1.1 \n");
out.write("Host:www.facebook.com \n);

The above lines work when the host is www.google.com or any other website.
So, do I have to change the parameters in the GET request for Facebook.

There are several fields in the Request header that the server can look at to decide if it wants to serve you. Try changing one/some of those to convince the server to serve you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.