我已经在我的android项目中实现了facebook。我正在使用一个共享按钮,它应该向用户时间表发布一条新消息。一切正常,但我想尝试一下这个应用程序,而没有在我的手机上安装Facebook应用程序。
我已经卸载facebook,清除缓存,清除所有数据,从设置中删除"Facebook帐户“并重新启动电话。之后,我按下应用程序中的共享按钮,帖子就在我的时间线上了!这怎么可能?我把所有东西都卸载了!
这是密码。我不知道这会不会有什么帮助。
消防
@Override
public void onClick(View v)
{
switch(v.getId())
{
case R.id.btnFacebook:
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()){
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null){
publishStory();
}
}
});
}
}
});
break;
}
}
private void publishStory() {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", "Something...");
postParams.putString("caption", "My caption...");
postParams.putString("description", "Awesomedescription");
postParams.putString("link", "http://www.domain.com");
postParams.putString("picture", "http://www.domain.com/image.png");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
Log.i("DEB", " SUCCESS POSTED TIMELINE ! ");
} catch (JSONException e) {}
FacebookRequestError error = response.getError();
if (error != null) {
} else {
Toast.makeText(getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}发布于 2013-08-12 16:26:35
Facebook应用程序和你的应用程序根本就没有联系在一起。一旦您的应用程序获得访问令牌,它就属于您保留和重用(即使您删除Facebook应用程序)。
SDK中的Session类将自动缓存令牌以供重用(这样,当您打开一个新会话时,它不会再次向用户请求权限)。如果您想将用户从应用程序中注销,您应该在应用程序关闭时(或者当用户选择退出时)调用session.closeAndClearTokenInformation()。
https://stackoverflow.com/questions/18165776
复制相似问题