Теперь я пытаюсь использовать python для кодирования одного проекта CMS для контактов, но у меня есть некоторые проблемы.
Я кодирую этот def, но он не работает с API Google People. https://developers.google.com/people/v1/contacts
Журналы
File "/Users/nguyenngoclinh/.conda/envs/1z_vietnam/lib/python3.7/site-packages/googleapiclient/http.py", line 907, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://people.googleapis.com/v1/%7B'people/c9194159806299427121'%7D:deleteContact?alt=json returned "Not Found">
функция удаления приведена ниже
def delete_contacts_with_resourceName(creds,http,number_of_contact):
# Call the People API
service = build('people', 'v1', credentials=creds)
print('Ban dang xoa', number_of_contactcontact, 'contacts')
results = service.people().connections().list(
resourceName='people/me',
pageSize=number_of_contactofcontact,
personFields='names,emailAddresses,phoneNumbers,emailAddresses,addresses').execute()
service = discovery.build('people', 'v1', http=http,
discoveryServiceUrl='https://people.googleapis.com/$discovery/rest')
connections = results.get('connections', [])
for person in connections:
abcd = person.get('resourceName')
service.people().deleteContact(resourceName={abcd}).execute()
Но приведенная ниже функция creat contact def также работает.
def creat_a_google_contact(http):
# POST / v1 / people: createContact
# HTTP / 1.1
# Body: {"names": [{"givenName": "John", "familyName": "Doe"}]}
# Host: people.googleapis.com
service = discovery.build('people', 'v1', http=http,
discoveryServiceUrl='https://people.googleapis.com/$discovery/rest')
service.people().createContact(body={
"names": [
{
'givenName': "Nguyen Ngoc Linh",
"familyName": "29N2359 BMW 325i"
}
],
"phoneNumbers": [
{
'value': "0979955664"
}
],
"emailAddresses": [
{
'value': "bk.nguyenlinh@gmail.com"
}
],
"addresses": [
{
"streetAddress": "So 1 ngo 85 Lang Ha",
"extendedAddress": "Ba Dinh",
"city": "Ha Noi",
"region": "Ha Noi",
"postalCode": "10000",
"country": "Vietnam",
"countryCode": "84"
}
]
}).execute()
def main, пожалуйста, помогите мне
def main():
creds = get_credentials(FLOW)
# print_list_google_contact_with_number_of_contacts(creds,1000)
http=get_http(creds)
#creat_a_google_contact(http)
# print_result(creds)
delete_contacts_with_resourceName(creds,http,1000)
#print_resourceName(creds, 2000)