我正在尝试将Facebook ** 集成到我的 android 应用程序中。我想在 **facebook 上实现 **like和share ** 设施。但我收到错误。
请帮我解决这个问题。
我也想知道在 Facebook 上创建新应用的过程。
我正在使用来自GitHub的代码。我的代码是 -
public class MyGreatActivity extends Activity {
Facebook facebook = new Facebook("333778590046892");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
facebook.authorize(this, new String[] { "offline_access", "publish_stream", "raj21kadam@gmail.com" },
new DialogListener() {
@Override
public void onComplete(Bundle values) {
String token=facebook.getAccessToken(); //get access token
// Toast.makeText(this, "token", Toast.LENGTH_LONG).
save(token);
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
private void save(String token){
Toast.makeText(this, "token"+token, Toast.LENGTH_LONG).show();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putString("Token", token).commit();
}
}
运行上述代码时出现以下错误 -
Dialog Errorcom.facebook.android.DialogError: The connection to the server was unsuccessful.