The Facebook APIs are HTTP-based, so you can issue a HTTP post request from your game to the appropriate API endpoint (see "Publish a Post," which unfortunately has no anchor). The endpoint in question is me/feed
, so you'll want to construct a request that looks basically like this:
http://graph.facebook.com/me/feed?message="SCORES HERE"&access_token=X
(You'll have to make sure to follow the steps for authentication detailed in the documentation to get the access token you should pass instead of X
).
You should be able to use HttpUrlConnection
approximately as follows (untested, sortof-pseudocode):
url = new URL("http://graph.facebook.com/me/feed");
connection = (HttpURLConnection) url.openConnection();
// Indicates POST.
connection.setDoOutput(true);
// Encode parameters.
StringBuffer parameters = new StringBuffer();
parameters.append(URLEncoder.encode("message", "UTF-8"));
parameters.append("=");
parameters.append(URLEncoder.encode("\"Score Data Here\"", "UTF-8"));
parameters.append(URLEncoder.encode("access_token, "UTF-8"));
parameters.append("=");
parameters.append(URLEncoder.encode("Access Token Here", "UTF-8"));
// Transmit data.
writer = new OutputStreamWriter(connection.getOutputStream());
writer.write(parameters.toString());
writer.flush();