如何实现面料数字找朋友?
Posted
技术标签:
【中文标题】如何实现面料数字找朋友?【英文标题】:How to implement find friends with fabric digits? 【发布时间】:2016-12-20 17:35:08 【问题描述】:如何实现织物数字找朋友?
我已成功实施手机号码验证,但我无法上传联系人并获取匹配的联系人..每次我都遇到同样的错误
错误:超出速率限制
下面是实现
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);
);
收货人
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);
联系人类
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
);
【问题讨论】:
【参考方案1】:Twitter 会限制您在特定时间范围内向其 API 发出的请求数量。所以你达到了这个极限。如果抛出速率限制异常,您需要修改逻辑以限制您的请求或等待一段时间。
他们的docs page关于速率限制非常彻底,所以我建议检查一下。
【讨论】:
以上是关于如何实现面料数字找朋友?的主要内容,如果未能解决你的问题,请参考以下文章