1
1
# -*- coding: UTF-8 -*-
2
2
import requests as req
3
- import json ,sys ,time , random
3
+ import json ,sys ,time
4
4
#先注册azure应用,确保应用有以下权限:
5
5
#files: Files.Read.All、Files.ReadWrite.All、Sites.Read.All、Sites.ReadWrite.All
6
6
#user: User.Read.All、User.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All
13
13
14
14
15
15
path = sys .path [0 ]+ r'/1.txt'
16
- path2 = sys .path [0 ]+ r'/time.log'
17
16
num1 = 0
18
17
19
18
def gettoken (refresh_token ):
@@ -35,10 +34,7 @@ def gettoken(refresh_token):
35
34
def main ():
36
35
fo = open (path , "r+" )
37
36
refresh_token = fo .read ()
38
- fo .close ()
39
- fv = open (path2 , "r+" )
40
- timelog = fv .read ()
41
- fv .close ()
37
+ fo .close ()
42
38
global num1
43
39
localtime = time .asctime ( time .localtime (time .time ()) )
44
40
access_token = gettoken (refresh_token )
@@ -65,7 +61,7 @@ def main():
65
61
if req .get (r'https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules' ,headers = headers ).status_code == 200 :
66
62
num1 += 1
67
63
print ('6调用成功' + str (num1 )+ '次' )
68
- if req .get (r'https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules ' ,headers = headers ).status_code == 200 :
64
+ if req .get (r'https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/delta ' ,headers = headers ).status_code == 200 :
69
65
num1 += 1
70
66
print ('7调用成功' + str (num1 )+ '次' )
71
67
if req .get (r'https://graph.microsoft.com/v1.0/me/drive/root/children' ,headers = headers ).status_code == 200 :
@@ -80,9 +76,9 @@ def main():
80
76
if req .get (r'https://graph.microsoft.com/v1.0/me/outlook/masterCategories' ,headers = headers ).status_code == 200 :
81
77
num1 += 1
82
78
print ('10调用成功' + str (num1 )+ '次' )
83
- print ('此次运行时间为 :' , localtime )
79
+ print ('此次运行结束时间为 :' , localtime )
84
80
except :
85
81
print ("pass" )
86
82
pass
87
- for _ in range (random . randint ( 10 , 100 ) ):
83
+ for _ in range (5 ):
88
84
main ()
0 commit comments