I am trying to integrate my application with social networks (facebook and twitter).
I want to have acess for exemple to a user wall or to a public wall and post it in my layout, like a scroll view or a item view (or any sugestions!!!), this is solved for twitter, but i can not put that work to facebook.
I use the Graph API.
To do a post in my wall i create the method postTextOnMyWall:
public String postTextOnMyWall(String message) {
Log.d("Tests", "Testing graph API wall post");
try {
Bundle parameters = new Bundle();
parameters.putString("message", message);// key/value
this.mAsyncRunner.request("me/feed", parameters, "POST",
new WallPostTextRequestListener(), null);
} catch (Exception e) {
e.printStackTrace();
}
return message;
}
public AsyncFacebookRunner getmAsyncRunner() {
return this.mAsyncRunner;
}
public void setmAsyncRunner(AsyncFacebookRunner mAsyncRunner) {
this.mAsyncRunner = mAsyncRunner;
}
}
This method as listener for posting text messages, WallPostTextRequestListener
public class WallPostTextRequestListener implements RequestListener {
public void showToast(String message) {
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT)
.show();
}
// called on successful completion of the Request
@Override
public void onComplete(String response, Object state) {
Log.d("WallPostTextRequestListener", "Got response: " + response);
String message = "<empty>";
try {
JSONObject json = Util.parseJson(response);
message = json.getString("message");
showToast("Mensagem escrita no teu mural facebook!: " + message);
} catch (JSONException e) {
Log.e("WallPostTextRequestListener", "JSON Error in response");
} catch (FacebookError e) {
Log.e("WallPostTextRequestListener",
"Facebook Error: " + e.getMessage());
}
final String text = "Mensagem: " + message;
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
// called if there is an error
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}
}
And them i just use a object of the facebook login to do a post in an onClick button
// this is the editext where i write my post
String messageFace = ((EditText) findViewById(R.id.message))
.getText().toString();
lf.postTextOnMyWall(messageFace);
How can i do the same to get the feed from my wall or a public page? Thanks in advance!