[英]How post message on facebook without open any dialog?
I want to post messages on facebook without open dialog using native Facebook android app. 我想使用本机Facebook android应用程序在Facebook上发布消息而无需打开对话框。 I am using facebook sdk 3.5.2.
我正在使用Facebook SDK 3.5.2。 I have successfully post messages on wall.
我已成功在墙上张贴消息。
I am facing some problems. 我面临一些问题。
1) if I logout from native Facebook app. 1)如果我从本地Facebook应用程序注销。 Then it post messages to previous user's Facebook wall & it not ask for authentication.
然后,它将消息发布到先前用户的Facebook墙,并且不要求身份验证。
2)If user login with different account in Facebook native app, it still post messages to previous account( which login first time through app). 2)如果用户在Facebook本机应用程序中使用其他帐户登录,它仍会将消息发布到以前的帐户(该帐户首次通过应用程序登录)。 Not ask for authentication.
不要求认证。
Code:- 码:-
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
new messagePostAsyn().execute(session);
}
}
});
Method: 方法:
private void postStatus(final Session session, String message) {
Bundle _postParameter = new Bundle();
_postParameter.putString("name", message);
_postParameter.putByteArray("picture", bytes);
_postParameter.putString("caption", "To help....");
_postParameter.putString("description", "Testing...");
Request request = new Request(session, "me/photos", _postParameter,
HttpMethod.POST, new Callback() {
@Override
public void onCompleted(Response response) {
// TODO Auto-generated method stub
System.out.println("response......" + response);
}
});
Request.executeBatchAsync(request);
}
This method used in messagePostAsyn() class. 此方法在messagePostAsyn()类中使用。
Try this Code : 试试这个代码:
public void postToWall(String message) {
Bundle params = new Bundle();
params.putString("message", message);
// Uses the Facebook Graph API
try {
facebook.request("/me/feed", params, "POST");
this.finish();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.