简体   繁体   中英

How to implement find friends with fabric digits?

how to implement find friends with fabric digits?

i have successfully implemented mobile number verification but im unable to upload contacts and get matched contacts .. every time i get same error

error : Rate limit exceeded

below is implementation

registerReceiver(new MyResultReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            super.onReceive(context, intent);
            if (ContactsUploadService.UPLOAD_COMPLETE.equals(intent.getAction())) {
                ContactsUploadResult result = intent.getParcelableExtra(ContactsUploadService.UPLOAD_COMPLETE_EXTRA);
                Log.e("upload", result.totalCount + "  " + result.successCount);
            }
        }
    }, new IntentFilter("com.digits.sdk.android.UPLOAD_COMPLETE"));
    sharedPreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
    Ref = FirebaseDatabase.getInstance().getReference().child("Users");


    DigitsAuthButton digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
    digitsButton.setCallback(new AuthCallback() {
        @Override
        public void success(DigitsSession session, String phoneNumber) {
            // TODO: associate the session userID with your user model
            phone = session.getPhoneNumber();
            digitsId = String.valueOf(session.getId());
            Toast.makeText(getApplicationContext(), "Authentication successful for "
                    + phoneNumber, Toast.LENGTH_LONG).show();
            Log.e("number", "Mobile Number:  " + phoneNumber);
            Log.e("digit", "DigitsID  " + session.getAuthToken() + "  " + session.getId());
            // Digits.getInstance().getActiveSession();
            sendDigitANdNumber(String.valueOf(session.getId()), phoneNumber);
            // startService(new Intent(PhoneVerification.this, MyResultReceiver.class));

            startActivity(new Intent(PhoneVerification.this, RecentsTab.class));
            finish();


        }

        @Override
        public void failure(DigitsException exception) {
            Log.d("Digits", "Sign in with Digits failure", exception);
        }
    });


}

Receivr

public class MyResultReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (ContactsUploadService.UPLOAD_COMPLETE.equals(intent.getAction())) {
            ContactsUploadResult result = intent.getParcelableExtra(ContactsUploadService.UPLOAD_COMPLETE_EXTRA);

        }
    }



}

Contacts class

find.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ContactMatch();
            }
        });

     private void ContactMatch() {
        Digits.uploadContacts();
        progressDialog.show();

        Digits.findFriends(new ContactsCallback<Contacts>() {

            @Override
            public void success(Result<Contacts> result) {
                if (result.data.users != null) {
                    // Process data
                    progressDialog.dismiss();
                    linearLayout.setVisibility(View.GONE);
                    Log.e("data", result.toString());
                }
            }

            @Override
            public void failure(TwitterException exception) {
                progressDialog.dismiss();
                // Show error
            }
        });
    }

Twitter limits the number of requests you can make to their API within a certain timeframe. So you are hitting this limit. You need to modify your logic to either throttle your requests or wait for a set amount of time if the Rate Limit exception is thrown.

Their docs page on rate limiting is pretty thorough, so I recommend checking that out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM