I want to send post on wall in facebook. So, I login with my own button:
LoginManager.getInstance().logInWithPublishPermissions(MainActivity.this, Arrays.asList("publish_actions"));
And then send post using Graph API:
Bundle params = new Bundle();
params.putString("message", "This is a test message");
new GraphRequest(AccessToken.getCurrentAccessToken(),
"/me/feed",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse){
}
}).executeAsync();
Code is working but not always. I press button, message send, again click on the button - the message is not sent. After some time the button is pressed again - sent.
Also if I use this code:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle("Title")
.setContentDescription("Description")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
ShareApi.share(content, null);
It works good. What is problem? What is the error?
0 comments:
Post a Comment