Reputation: 4345
I am using Facebook sdk, (https://github.com/facebook/facebook-android-sdk/) to show the NewsFeed. I can be show the all newsfeed wall in my application.
Now I need to send the comment on the any wall which is visible by me. And how I can be like the wall and the comment through my application. Can anybody plz help me in this?
Thanks in advance.
Upvotes: 2
Views: 5773
Reputation: 25918
You should get familiar with Facebook Android SDK usage of Graph API, Post object (comments connection) and Comment Object Graph API documentation (likes section).
Update:
Example below about creating comment and liking it (samples of how to create comment for post and like the post already shown in other answer to this question):
// I assume you already have post_id (which is constructed from USERID_MESSAGEID)
Facebook mFacebook = new Facebook(APP_ID);
Bundle params = new Bundle();
params.putString("message", "This is a comment text");
String comment_id = facebook.request(post_id + "/comments", params, "POST");
// Once you have comment_id it can be used for liking it.
facebook.request(comment_id + "/likes", new Bundle(), "POST");
Upvotes: 0
Reputation: 1932
You can parse all feeds using graph api by passing
mAsyncRunner.request("me/home", params, new graphApiRequestListener());
it returns you json data with all your post and comments and likes you can parse that data get all commnets
for further information search for hackbook for android example
Upvotes: 0
Reputation: 1485
To be clear:
Using the Facebook SDK you can do the following for comments:
Facebook facebook = new Facebook(APP_ID);
String commentText = "I love blu-ray";
String postId = "7568536355_333422146668093"; //a lifehacker post about blu-ray
String graphPath = postId + "/comments";
Bundle params = new Bundle();
params.putString("message", commentText);
facebook.request(graphPath, params, "POST");
... and the following for likes:
Facebook facebook = new Facebook(APP_ID);
String postId = "7568536355_333422146668093"; //a lifehacker post about blu-ray
String graphPath = postId + "/likes";
facebook.request(graphPath, new Bundle(), "POST");
Upvotes: 7
Reputation: 2562
'Use Facebook Api as library download api and use it as library'
private static final String FACEBOOK_APPID = "Your Api key";
Facebook facebook = new Facebook(FACEBOOK_APPID);
facebook.authorize(this,new String[] { "user_photos,publish_checkins,publish_actions,publish_stream" },
new DialogListener() {
@Override
public void onComplete(Bundle values) {
postImageonWall();
try {
facebook.logout(TestActivity.this);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// finish();
}
@Override
public void onFacebookError(FacebookError error) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onCancel() {
}
use postImageOnWall method
public void postImageonWall() {
byte[] data = null;
Bitmap bi = BitmapFactory.decodeFile(filepath);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST", new RequestListener() {
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
Log.d("MalformedURLException", e.getMessage());
}
@Override
public void onIOException(IOException e, Object state) {
Log.d("onIOException", e.getMessage());
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
Log.d("FileNotFoundException", e.getMessage());
}
@Override
public void onFacebookError(FacebookError e, Object state) {
Log.d("onFacebookError", e.getMessage());
}
@Override
public void onComplete(String response, Object state) {
Log.d("onComplete", response);
}
}, null);
}
Upvotes: -1