我的Android应用程序曾经能够通过API连接到Facebook服务器,但现在它不会出于某种原因。我继续在我的日志猫中收到此消息
D / Facebook-authorize(417):登录失败:com.facebook.android.DialogError:与服务器的连接失败。
我已经阅读了很多有关此问题的堆栈溢出问题,但没有回答。我希望有人能帮助我。谢谢!
以下是我的一些代码,其中我的App ID已被删除
public class BreadcrumbsActivity extends Activity {
static Facebook facebook = new Facebook("*************");
String FILENAME = "AndroidSSO_data";
static SharedPreferences mPrefs;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*
* Get existing access_token if any
*/
mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
/*
* Only call authorize if the access_token has expired.
*/
if(!facebook.isSessionValid()) {
facebook.authorize(this, new String[] {"user_likes", "user_photos", "email", "offline_access", "publish_actions"}, new DialogListener() {
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", facebook.getAccessToken());
editor.putLong("access_expires", facebook.getAccessExpires());
editor.commit();
Toast.makeText(getApplicationContext(),
"Login Succesful.",
Toast.LENGTH_LONG).show();
Intent intent = new Intent(BreadcrumbsActivity.this, MainMenu.class);
BreadcrumbsActivity.this.startActivity(intent);
}
@Override
public void onFacebookError(FacebookError error) {
Toast.makeText(getApplicationContext(),
"Login Failed.",
Toast.LENGTH_LONG).show();
Intent intent = new Intent(BreadcrumbsActivity.this, MainMenu.class);
BreadcrumbsActivity.this.startActivity(intent);
}
@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);
}
}
答案 0 :(得分:0)
错误 - 417期望失败
417状态代码表示服务器无法正常运行 完成请求。其中一个头发送到服务器, “Expect”标题表示期望服务器无法满足。