【发布时间】:2014-04-02 17:16:52
【问题描述】:
我知道这是一个以前回答过的问题,但似乎没有人工作,我在 int 上花了一周时间。
我试图从 key 工具中获取我的 Key Hash 并将它们放在 Facebook 应用 Key hashes 上,发布和调试。没有人工作。 “(404) 密钥哈希 xxxxxxxxxxxx 不匹配任何存储的密钥哈希” 这很少见,我的钥匙不一样。
所以我尝试了:
PackageInfo info = getPackageManager().getPackageInfo(
"com.pakage.example",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String result = Base64.encodeToString(md.digest(), Base64.DEFAULT);
Toast.makeText(MainActivity.this , result + result.toUpperCase(), Toast.LENGTH_LONG).show();
}
这向我返回了 Facebook (xxxxxxxxxxxx) 的相同密钥请求,因此我将它们添加到 Facebook 应用程序,但 Facebook 向我返回“(404) 密钥哈希 xxxxxxxxxxxx 与任何存储的密钥哈希不匹配”。
当我从我的设备中删除 Facebook 应用程序时,我可以通过 WebDialog 分享状态。
我的最终代码似乎是:
if (FacebookDialog.canPresentShareDialog(parent, FacebookDialog.ShareDialogFeature.SHARE_DIALOG))
{
publishFacebookDialog(points); //FacebookDialog
}
else
{
Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
publishFeedDialog(points); //WebDialog
}
else
{
Intent intent = new Intent(parent, LoginUsingCustomFragmentActivity.class); //From FacebookSDK demo
parent.startActivityForResult(intent, 666);
}
}
PublishFacebookDialog 函数:
private void publishFacebookDialog(String puntuacion) {
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(parent)
.setLink("bla")
.setCaption("bla")
.setName("bla")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
PublishFeedDialog 函数:
private void publishFeedDialog(String puntuacion) {
Bundle params = new Bundle();
params.putString("name", "bla");
params.putString("caption", "bla");
params.putString("link", "bla");
WebDialog feedDialog = ( new WebDialog.FeedDialogBuilder(parent,Session.getActiveSession(),params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
if (error == null) {
final String postId = values.getString("post_id");
if (postId != null) {
} else {
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
} else {
// Generic, ex: network error
}
}
})
.build();
feedDialog.show();
}
LoginUsingCustomFragmentActivity 类与 FacebookSDK 相同
试过了:
- 从 facebook 中删除应用并重新添加。
- 替换其他已回答帖子中的 /_+ 等符号。
- 使用 Facebook 应用上“(404) Key hash xxxxxxxxxxxx does not ....”报告的相同密钥哈希。
有什么想法吗?
非常感谢。
【问题讨论】:
-
同样是我的问题
-
我有时在从 Chrome 添加密钥哈希时遇到问题,您是否尝试过从不同浏览器添加密钥?