It works fine with checking one or two accounts:
result = bom.check_account(’@clayadavis’)
However, when I read a list of twitter accounts, that looks lie below, it gives me 401 Client Error:
0 unwomenindia
1 SkyNews
2 Jerusalem_Post
3 gujratsamachar
4 nayibbukele
…
52955 me_kimba
52956 Yelix
52957 herculezg
52958 malcolmkenyatta
52959 ainsleyoc
Name: user_screen_name, Length: 52960, dtype: object
Just to note, I have Check accounts in bulk and Check account v4. When run “Test Endpoint”, Check accounts in bulk gives 401 Client Error. Check account v4 runs without error. Can you please advise?
הצטרף לדיון - הוסף תגובה למטה:
Glad to hear that it works now.
Ok, the same script runs now. It seems like that Botometer side server is not stable, so it throws 401 error once in a while (irregularly). Thanks so much for responding to me though…
My guess is that your API key has been suspended by Twitter. We are sorry about that. ==> No, it works now. So, this cannot be it.
The check accounts in bulk error might be due to that you haven’t subscribed to the corresponding plan. ==> Does this mean that this could cause the 401 error? If so, can you guide me which subscription is necessary to activate this?
OK, now I’ve run the couple of accounts successfully using your example code:
Check a single account by screen name
result = bom.check_account(’@clayadavis’)
Check a single account by id
result = bom.check_account(1548959833)
print(result)
Check a sequence of accounts
accounts = [’@clayadavis’, ‘@onurvarol’]
for screen_name in accounts:
result = bom.check_account(screen_name)
print(result)
But I still have the 401 error from the first line of the following code:
FYI: “list of handels” include values like this: [’@unwomenindia’, ‘@SkyNews’, ‘@Jerusalem_Post’, ‘@gujratsamachar’, ‘@nayibbukele’, ‘@ThaiPBSNews’, …]
for screen_name, result in bom.check_accounts_in(list_of_handles):
print(_index)
if(‘user’ not in list(result.keys())):
print(result)
if (‘error’ in list(result.keys())):
if ‘34’ in result[‘error’] :
data = {
‘userID’: ‘none’,
‘username’: list_of_handles[_index],
‘cap_universal’: -1,
‘status’: “deleted”
}
df = pd.DataFrame(data, index=[_index])
list_of_df.append(df)
_index = _index + 1
else:
data = {
‘userID’: ‘none’,
‘username’: list_of_handles[_index],
‘cap_universal’: -1,
‘status’: “suspended”
}
df = pd.DataFrame(data, index=[_index])
list_of_df.append(df)
_index = _index + 1
else:
data = {
‘userID’: result[‘user’][‘user_data’][‘id_str’],
‘username’: list_of_handles[_index],
‘cap_universal’: result[‘cap’][‘universal’],
‘status’: “active”
}
df = pd.DataFrame(data, index=[_index])
list_of_df.append(df)
_index = _index + 1
current_date = str(datetime.datetime.today()).split()[0]
final = pd.concat(list_of_df)
final.to_csv(‘botometer/botometer_output/verified_bots/verified_bots_{}.csv’.format(current_date))
My guess is that your API key has been suspended by Twitter. We are sorry about that.
The check accounts in bulk error might be due to that you haven’t subscribed to the corresponding plan.
–Botometer
401 error usually indicates that your API key has been deactivated. Please make sure you still have access to the V1.1 API of Twitter.
Also, it would be helpful if you could share the full code snippet you used when you encountered the error. It’s hard to tell what went wrong with the information you provided.
–Botometer Team