用户API
在Zoho CRM中,用户是被允许访问和管理CRM记录的人。这些用户可以在不同的配置文件和类别下定义,比如管理员、标准等等。
使用用户API,您可以检索可用CRM用户的基本信息。使用type参数获取所需的用户列表。例如,可以将参数类型设置为AdminUsers,获取具有管理员角色的CRM用户。用户API的详细说明和示例如下:
获取用户
目的
检索API请求中指定的用户数据。您可以指定需要使用用户API检索的用户类型。例如,使用 type=AllUsers,获取所有可用CRM用户的列表。
请求URL
https://www.zohoapis.com.cn/crm/v2/users
请求方法
GET
范围
scope=ZohoCRM.users.{operation_type}
可能的操作类型 |
---|
ALL - 完全访问用户 READ - 获取用户数据 |
参数
参数名称 | 数据类型 | 描述 |
---|---|---|
类型 | 字符串 | AllUsers列出机构中的所有用户(包括活动用户和非活动用户) ActiveUsers获取所有活动用户的列表 DeactiveUsers获取已停用的所有用户的列表 ConfirmedUsers获取已确认用户的列表 NotConfirmedUsers获取未确认用户的列表 DeletedUsers获取已删除用户的列表 ActiveConfirmedUsers获取也已确认的活动用户列表 AdminUsers获取管理用户列表。 ActiveConfirmedAdmins以获取具有管理权限的活动用户列表,并得到确认 CurrentUser获取当前CRM用户 |
示例请求
curl "https://www.zohoapis.com.cn/crm/v2/users?type=AllUsers"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
示例响应
{
"users": [
{
"country": null,
"role": {
"name": "CEO",
"id": "2445013000000026005"
},
"city": null,
"signature": null,
"name_format": "Salutation,First Name,Last Name",
"language": "en_US",
"locale": "en_US",
"personal_account": true,
"default_tab_group": "0",
"street": null,
"alias": "Charan",
"theme": {
"normal_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"selected_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"new_background": "#018EE0",
"background": "#F3F0EB",
"screen": "fixed",
"type": "default"
},
"id": "2445013000000114007",
"state": null,
"country_locale": "en_US",
"fax": null,
"first_name": "Particia",
"email": "p.boyle@zylker.com",
"zip": null,
"decimal_separator": "en_IN",
"website": null,
"time_format": "hh:mm a",
"profile": {
"name": "Administrator",
"id": "2445013000000026011"
},
"mobile": null,
"last_name": "Boyle",
"time_zone": "IST",
"zuid": "11290182",
"confirm": true,
"full_name": "Patricia Boyle",
"territories": [],
"phone": null,
"dob": null,
"date_format": "MM/dd/yyyy",
"status": "active"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
ZCRMRestClient client = ZCRMRestClient.getInstance();
BulkAPIResponse response = client.getOrganisationInstance().getAllUsers();
List<ZCRMUser> users = (List<ZCRMUser>) response.getData();
示例响应
{
"users": [
{
"country": null,
"role": {
"name": "CEO",
"id": "2445013000000026005"
},
"city": null,
"signature": null,
"name_format": "Salutation,First Name,Last Name",
"language": "en_US",
"locale": "en_US",
"personal_account": true,
"default_tab_group": "0",
"street": null,
"alias": "Charan",
"theme": {
"normal_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"selected_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"new_background": "#018EE0",
"background": "#F3F0EB",
"screen": "fixed",
"type": "default"
},
"id": "2445013000000114007",
"state": null,
"country_locale": "en_US",
"fax": null,
"first_name": "Particia",
"email": "p.boyle@zylker.com",
"zip": null,
"decimal_separator": "en_IN",
"website": null,
"time_format": "hh:mm a",
"profile": {
"name": "Administrator",
"id": "2445013000000026011"
},
"mobile": null,
"last_name": "Boyle",
"time_zone": "IST",
"zuid": "11290182",
"confirm": true,
"full_name": "Patricia Boyle",
"territories": [],
"phone": null,
"dob": null,
"date_format": "MM/dd/yyyy",
"status": "active"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
def get_users(self,user_type):
try:
if user_type=='all':
resp=ZCRMOrganization.get_instance().get_all_users()
elif user_type=='DeactiveUsers':
resp=ZCRMOrganization.get_instance().get_all_deactive_users()
elif user_type=='ActiveUsers':
resp=ZCRMOrganization.get_instance().get_all_active_users()
elif user_type=='ConfirmedUsers':
resp=ZCRMOrganization.get_instance().get_all_confirmed_users()
elif user_type=='NotConfirmedUsers':
resp=ZCRMOrganization.get_instance().get_all_not_confirmed_users()
elif user_type=='DeletedUsers':
resp=ZCRMOrganization.get_instance().get_all_deleted_users()
elif user_type=='ActiveConfirmedUsers':
resp=ZCRMOrganization.get_instance().get_all_active_confirmed_users()
elif user_type=='AdminUsers':
resp=ZCRMOrganization.get_instance().get_all_admin_users()
elif user_type=='ActiveConfirmedAdmins':
resp=ZCRMOrganization.get_instance().get_all_active_confirmed_admin_users()
elif user_type=='CurrentUser':
resp=ZCRMOrganization.get_instance().get_current_user()
print resp.status_code
if resp.status_code!=200:
return
users=resp.data
for user in users:
print "\n\n"
print user.id
print user.name
print user.signature
print user.country
crm_role=user.role
if crm_role is not None:
print crm_role.name
print crm_role.id
customize_info= user.customize_info
if customize_info is not None:
print customize_info.notes_desc
print customize_info.is_to_show_right_panel
print customize_info.is_bc_view
print customize_info.is_to_show_home
print customize_info.is_to_show_detail_view
print customize_info.unpin_recent_item
print user.city
print user.name_format
print user.language
print user.locale
print user.is_personal_account
print user.default_tab_group
print user.street
print user.alias
user_theme=user.theme
if user_theme is not None:
print user_theme.normal_tab_font_color
print user_theme.normal_tab_background
print user_theme.selected_tab_font_color
print user_theme.selected_tab_background
print user.state
print user.country_locale
print user.fax
print user.first_name
print user.email
print user.zip
print user.decimal_separator
print user.website
print user.time_format
crm_profile= user.profile
if crm_profile is not None:
print crm_profile.id
print crm_profile.name
print user.mobile
print user.last_name
print user.time_zone
print user.zuid
nbsp; print user.is_confirm
print user.full_name
print user.phone
print user.dob
print user.date_format
print user.status
except ZCRMException as ex:
print ex.status_code
print ex.error_message
print ex.error_code
print ex.error_details
print ex.error_content
示例响应
{
"users": [
{
"country": null,
"role": {
"name": "CEO",
"id": "2445013000000026005"
},
"city": null,
"signature": null,
"name_format": "Salutation,First Name,Last Name",
"language": "en_US",
"locale": "en_US",
"personal_account": true,
"default_tab_group": "0",
"street": null,
"alias": "Charan",
"theme": {
"normal_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"selected_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"new_background": "#018EE0",
"background": "#F3F0EB",
"screen": "fixed",
"type": "default"
},
"id": "2445013000000114007",
"state": null,
"country_locale": "en_US",
"fax": null,
"first_name": "Particia",
"email": "p.boyle@zylker.com",
"zip": null,
"decimal_separator": "en_IN",
"website": null,
"time_format": "hh:mm a",
"profile": {
"name": "Administrator",
"id": "2445013000000026011"
},
"mobile": null,
"last_name": "Boyle",
"time_zone": "IST",
"zuid": "11290182",
"confirm": true,
"full_name": "Patricia Boyle",
"territories": [],
"phone": null,
"dob": null,
"date_format": "MM/dd/yyyy",
"status": "active"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
try{
$bulkAPIResponse=ZCRMOrganization::getInstance()->getAllUsers();
$users=$bulkAPIResponse->getData();
foreach($users as $userInstance)
{
echo $userInstance->getCountry();
$roleInstance=$userInstance->getRole();
echo $roleInstance->getId();
echo $roleInstance->getName();
$customizeInstance=$userInstance->getCustomizeInfo();
if($customizeInstance!=null)
{
echo $customizeInstance->getNotesDesc();
echo $customizeInstance->getUnpinRecentItem();
echo $customizeInstance->isToShowRightPanel();
echo $customizeInstance->isBcView();
echo $customizeInstance->isToShowHome();
echo $customizeInstance->isToShowDetailView();
}
echo $userInstance->getCity();
echo $userInstance->getSignature();
echo $userInstance->getNameFormat();
echo $userInstance->getLanguage();
echo $userInstance->getLocale();
echo $userInstance->isPersonalAccount();
echo $userInstance->getDefaultTabGroup();
echo $userInstance->getAlias();
echo $userInstance->getStreet();
$themeInstance=$userInstance->getTheme();
if($themeInstance!=null)
{
echo $themeInstance->getNormalTabFontColor();
echo $themeInstance->getNormalTabBackground();
echo $themeInstance->getSelectedTabFontColor();
echo $themeInstance->getSelectedTabBackground();
}
echo $userInstance->getState();
echo $userInstance->getCountryLocale();
echo $userInstance->getFax();
echo $userInstance->getFirstName();
echo $userInstance->getEmail();
echo $userInstance->getZip();
echo $userInstance->getDecimalSeparator();
echo $userInstance->getWebsite();
echo $userInstance->getTimeFormat();
$profile= $userInstance->getProfile();
echo $profile->getId();
echo $profile->getName();
echo $userInstance->getMobile();
echo $userInstance->getLastName();
echo $userInstance->getTimeZone();
echo $userInstance->getZuid();
echo $userInstance->isConfirm();
echo $userInstance->getFullName();
echo $userInstance->getPhone();
echo $userInstance->getDob();
echo $userInstance->getDateFormat();
echo $userInstance->getStatus();
}
}
catch(ZCRMException $e)
{
echo $e->getMessage();
echo $e->getExceptionCode();
echo $e->getCode();
}
示例响应
{
"users": [
{
"country": null,
"role": {
"name": "CEO",
"id": "2445013000000026005"
},
"city": null,
"signature": null,
"name_format": "Salutation,First Name,Last Name",
"language": "en_US",
"locale": "en_US",
"personal_account": true,
"default_tab_group": "0",
"street": null,
"alias": "Charan",
"theme": {
"normal_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"selected_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"new_background": "#018EE0",
"background": "#F3F0EB",
"screen": "fixed",
"type": "default"
},
"id": "2445013000000114007",
"state": null,
"country_locale": "en_US",
"fax": null,
"first_name": "Particia",
"email": "p.boyle@zylker.com",
"zip": null,
"decimal_separator": "en_IN",
"website": null,
"time_format": "hh:mm a",
"profile": {
"name": "Administrator",
"id": "2445013000000026011"
},
"mobile": null,
"last_name": "Boyle",
"time_zone": "IST",
"zuid": "11290182",
"confirm": true,
"full_name": "Patricia Boyle",
"territories": [],
"phone": null,
"dob": null,
"date_format": "MM/dd/yyyy",
"status": "active"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}
示例请求
ZCRMRestClient restClient = ZCRMRestClient.GetInstance();
BulkAPIResponse<ZCRMUser> response = restClient.GetOrganizationInstance().GetAllUsers();
List<ZCRMUser> allUsers = response.BulkData; //response - ZCRMUser实例列表
示例响应
{
"users": [
{
"country": null,
"role": {
"name": "CEO",
"id": "2445013000000026005"
},
"city": null,
"signature": null,
"name_format": "Salutation,First Name,Last Name",
"language": "en_US",
"locale": "en_US",
"personal_account": true,
"default_tab_group": "0",
"street": null,
"alias": "Charan",
"theme": {
"normal_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"selected_tab": {
"font_color": "#FFFFFF",
"background": "#222222"
},
"new_background": "#018EE0",
"background": "#F3F0EB",
"screen": "fixed",
"type": "default"
},
"id": "2445013000000114007",
"state": null,
"country_locale": "en_US",
"fax": null,
"first_name": "Particia",
"email": "p.boyle@zylker.com",
"zip": null,
"decimal_separator": "en_IN",
"website": null,
"time_format": "hh:mm a",
"profile": {
"name": "Administrator",
"id": "2445013000000026011"
},
"mobile": null,
"last_name": "Boyle",
"time_zone": "IST",
"zuid": "11290182",
"confirm": true,
"full_name": "Patricia Boyle",
"territories": [],
"phone": null,
"dob": null,
"date_format": "MM/dd/yyyy",
"status": "active"
}
],
"info": {
"per_page": 200,
"count": 1,
"page": 1,
"more_records": false
}
}