2

大家好,最近我正在通过 twitter 在 android 中为登录用户集成数字,现在以前它工作正常,但现在我不知道发生了什么,但在几次登录后它显示了这个错误

HTTP 错误:403 禁止,API 错误:239,用户消息:再试一次

现在有人可以告诉我我做错了什么也有人可以告诉我在消费者密钥和消费者秘密中我是否必须通过 dev.twiiter 我的应用程序凭据或结构消费者密钥和秘密,这件事真的很令人困惑,因为在他们提到了 twitter 键的文档,但在一些 stackoverflow 问题上人们说要使用数字键?另外我没有从应用程序扩展我的活动会导致任何问题吗?

我的代码在下面请告诉我我做错了什么这对我很有帮助

public class Signup_firststageActivity extends AppCompatActivity {


private AuthCallback authCallback;

public AuthCallback getAuthCallback(){
     return authCallback;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup_firststage);
    TextView text = (TextView)findViewById(R.id.text);
    Bundle b = getIntent().getExtras();
    if (b.getString("error") == null) {

} else {
    if (b.getString("error") != null && b.getString("error").equals("server_down")) {
        text.setText("Error 503 Please Try Again");
    } else {

    }
}
//Twitter

TextView tryagain = (TextView)findViewById(R.id.tryagain);
tryagain.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Digits.authenticate(new DigitsAuthConfig.Builder().withAuthCallBack(authCallback).withPhoneNumber("+918972745648").build());
    }
});
final TwitterAuthConfig authConfig =  new TwitterAuthConfig("agfjgD6wetDXdjfjuC4ywwoeD", "BshdjfjfwGz8WLaofkjfjsfjjsjsfhKpv60hQxni60oZwAu");
Fabric.with(getBaseContext(), new TwitterCore(authConfig), new Digits());
authCallback = new AuthCallback() {
    @Override
    public void success(DigitsSession session, String phoneNumber) {
        Log.d("digits", "success phoneNumber: " + phoneNumber);
        Log.d("digits", "session " + session.getPhoneNumber() + " " + session.toString() + " " + session.isValidUser() + " " + session.getAuthToken() + " " + session.getId());
        //    TwitterAuthConfig authConfig = TwitterCore.getInstance().getAuthConfig();
        progressDialog = new ProgressDialog(Signup_firststageActivity.this);
        progressDialog.setIndeterminate(true);
        progressDialog.setMessage("Please Wait... ");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.getWindow().setGravity(Gravity.CENTER);
        progressDialog.show();
        TwitterAuthToken authToken = (TwitterAuthToken) session.getAuthToken();

        OAuthSigning oauthSigning = new OAuthSigning(authConfig, authToken);
        Map<String, String> authHeaders = oauthSigning.getOAuthEchoHeadersForVerifyCredentials();
        Log.d("digits", "authHeaders: 1" + authHeaders);
        Signup_MobileNumber_requestData(session.getPhoneNumber());
        Digits.getSessionManager().clearActiveSession(); // don't know should i write this here or not ??
    }

    @Override
    public void failure(DigitsException exception) {
        Log.d("digits", "failure");
        // Do something on failure
    }
};

DigitsAuthButton digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
digitsButton.setCallback((this).getAuthCallback());
digitsButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Log.d("digits", "button click");

    }
});

}

先感谢您

4

1 回答 1

3

这个问题是因为 Key 和 Secret 的缘故。我试图从 Fabric 仪表板复制值,我得到了同样的错误。

当我从 Fabric-Android Studio Plugin->Digits->Install->Apply 获取值时,它起作用了

于 2017-03-23T12:17:21.620 回答