Unable to share on Facebook

泪湿孤枕 提交于 2020-01-16 18:27:06

问题


I have integrated Facebook SDK into my project. I have followed all the steps mentioned in https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/ .

But then also I am not able to share on facebook. I have generated the hash using debug.keystore and have placed it at 2 places as mentioned in the documentation.

Issue: I am able to share on facebook if native facebook android app is not installed in the device. i.e. via the pop up which ask for email id and password. I don't know why it doesn't share if facebook app is installed.

Edit: Even I downloaded the latest samples and sdk of Facebook which https://developers.facebook.com/android/ provides. There also I faced this same issue. Even I tried in many device.


回答1:


I am able to Proceed with this now. The issue was with key hash which I was including in facebook developers site. I was getting wrong key due to openssl. I got the correct one by including this piece of code:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
          YOUR_PACKAGE_NAME, PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) 
        {
           MessageDigest md = MessageDigest.getInstance("SHA");
           md.update(signature.toByteArray());
           Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    }
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

I got this while I was searching for alternative to generate the key hash.



来源:https://stackoverflow.com/questions/18405654/unable-to-share-on-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!