您好,我正在尝试在我的 android 应用程序中使用,例如 facebook 按钮。
我在这里寻找 facebook 提供的代码:
https://developers.facebook.com/docs/reference/opengraph/action-type/og.likes
和这里:
https://developers.facebook.com/docs/opengraph/guides/og.likes/#publishing
我添加了这种类型:
这是我的安卓代码:
class LikeTigoFacebook extends AsyncTask<String, Void, Void> {
protected Void doInBackground(String... args) {
Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
Bundle params = new Bundle();
params.putString("object",
"https://www.facebook.com/pages/Tigo/535949156477655");
Request request = new Request(Session.getActiveSession(),
"me/og.likes", params, HttpMethod.POST);
Response response = request.executeAndWait();
Log.i("check", response.getError().getErrorMessage());
Log.i("check2", response.toString());
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(Void file_url) {
}
}
我得到这个错误代码:
(#100) Like actions are not yet supported against objects of this type.
响应中的完整字符串是:
{Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 100, errorType: OAuthException, errorMessage: (#100) Like actions are not yet supported against objects of this type.}, isFromCache:false}
我的会话已打开,我在用户登录时添加了此权限:
private void onClickLogin() {
Session currentSession = Session.getActiveSession();
if (currentSession == null || currentSession.getState().isClosed()) {
Session session = new Session.Builder(RegisterPage.this).build();
Session.setActiveSession(session);
currentSession = session;
}
if (currentSession.isOpened()) {
// Do whatever u want. User has logged in
} else if (!currentSession.isOpened()) {
// Ask for username and password
OpenRequest op = new Session.OpenRequest(
(Activity) RegisterPage.this);
op.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);
op.setCallback(null);
List<String> permissions = new ArrayList<String>();
permissions.add("email");
permissions.add("publish_actions");
op.setPermissions(permissions);
Session session = new Session.Builder(RegisterPage.this).build();
Session.setActiveSession(session);
session.openForPublish(op);
}
}
我试着看这里:
它对我没有帮助,这似乎是一个旧答案。
感谢您的帮助