“如何整合”;例如;及;评论「;使用Android Facebook SDK的功能?
我想在我的应用程序中实现“喜欢”和“评论”功能。我使用了以下代码:“如何整合”;例如;及;评论「;使用Android Facebook SDK的功能?,android,facebook-graph-api,facebook-like,facebook-comments,Android,Facebook Graph Api,Facebook Like,Facebook Comments,我想在我的应用程序中实现“喜欢”和“评论”功能。我使用了以下代码: public static void like(String postID) { String grapPath = String.format("%s/likes", postID); Request request = new Request(Session.getActiveSession(), grapPath, null, HttpMethod.POST, new Callback() { @Overri
public static void like(String postID) {
String grapPath = String.format("%s/likes", postID);
Request request = new Request(Session.getActiveSession(), grapPath,
null, HttpMethod.POST, new Callback() {
@Override
public void onCompleted(Response response) {
Log.i(TAG, response.toString()+" Success!");
}
});
Request.executeBatchAsync(request);
}
public static void postComment(String comment, String postID) {
String grapPath = String.format("%s/comments", postID);
Bundle bundle = new Bundle();
bundle.putString("message", comment);
Request request = new Request(Session.getActiveSession(), grapPath,
bundle, HttpMethod.POST, new Callback() {
@Override
public void onCompleted(Response response) {
Log.i(TAG, "Success!");
}
});
Request.executeBatchAsync(request);
}
hh如何调用这些方法以及在哪里调用这些方法才能使其工作?请确保正确设置。具体检查步骤4的中间部分,以确保使用调试密钥库正确生成密钥哈希
否则下面的代码应该会有所帮助
private boolean hasPublishPermission() {
Session session = Session.getActiveSession();
return session != null && session.getPermissions().contains("publish_actions");
}
private void postStatusUpdate() {
if (hasPublishPermission()) {
final String message = "Posting to facebook";
Request request = Request
.newStatusUpdateRequest(Session.getActiveSession(), message, place, tags, new Request.Callback() {
@Override
public void onCompleted(Response response) {
showPublishResult(message, response.getGraphObject(), response.getError());
}
});
request.executeAsync();
} else {
pendingAction = PendingAction.POST_STATUS_UPDATE;
}
}
你让它工作了吗?谢谢你的关注,Pradeep!我让它工作了:)太好了,你能分享一些帮助你的资源吗?@Pradeep:是的,这段代码工作了,我的问题是我不知道怎么做use@SteveLuck你能分享代码吗?我有同样的问题,谢谢