我尝试编写一个可以登录 facebook 的应用程序。我使用 easyfacebooksdk.jar 之类的库来使用您的 API,但配置有问题。我发布了以下图片:这是我创建的 Facebook 应用程序:
我已经从控制台以这种方式获得了密钥哈希:
我把这段代码放在 key has 字段中(我不能发布图片,因为我没有 10 名声)
这是我的代码:
public class MainActivity extends Activity implements LoginListener {
private FBLoginManager fbManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
shareFacebook();
}
public void shareFacebook() {
//change the permissions according to the function you want to use
String permissions[] = { "read_stream", "user_relationship_details",
"user_religion_politics", "user_work_history",
"user_relationships", "user_interests", "user_likes",
"user_location", "user_hometown", "user_education_history",
"user_activities", "offline_access" };
//change the parameters with those of your application
fbManager = new FBLoginManager(this, R.layout.activity_main,
"334014040053829", permissions);
if (fbManager.existsSavedFacebook()) {
fbManager.loadFacebook();
} else {
fbManager.login();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
fbManager.loginSuccess(data);
}
public void loginFail() {
fbManager.displayToast("Login failed!");
}
public void logoutSuccess() {
fbManager.displayToast("Logout success!");
}
public void loginSuccess(Facebook facebook) {
//library use example
GraphApi graphApi = new GraphApi(facebook);
User user = new User();
try {
user = graphApi.getMyAccountInfo();
graphApi.setStatus("Post by app");
} catch (EasyFacebookError e) {
e.toString();
}
}
}
我在模拟器中收到此错误:app is misconfigured to facebook log in 但我不明白为什么...有人可以帮我吗?