Reputation: 10570
I want to share sometext on facebook using android facebook sdk 3.0.2
i tried this:
Bundle params = new Bundle();
params.putString("caption", "test");
params.putString("message", "test");
params.putString("link", "https://www.google.com");
// params.putString("picture", "picture_url");
Request request = new Request(Session.getActiveSession(),
"me/feed", params, HttpMethod.POST);
request.setCallback(new Request.Callback() {
@Override
public void onCompleted(Response response) {
if (response.getError() == null) {
Toast.makeText(About.this, "Successfully posted",
Toast.LENGTH_LONG).show();
} else
Toast.makeText(About.this, "An Error Has Happened",
Toast.LENGTH_SHORT).show();
}
});
request.executeAsync();
}
the toast is always printing an error has happened
Upvotes: 0
Views: 358
Reputation: 26
Session s = Session.getActiveSession();
Request request = Request.newStatusUpdateRequest(s, "your msg", new Request.Callback()
{
@Override
public void onCompleted(Response response)
{
if(response.getError()==null)
Toast.makeText(MainActivity.this, "Status updated successfully", Toast.LENGTH_LONG).show();
}
});
request.executeAsync();
this will post your message if you are signed in and have provided all the permissions.
Upvotes: 1