From c8015361f964a11afb822903a4dc8ac5540fa5cf Mon Sep 17 00:00:00 2001 From: iyear Date: Fri, 27 Mar 2020 16:31:09 +0800 Subject: [PATCH] Add OutLookGetMails Func --- outlook.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/outlook.go b/outlook.go index e375757..04919ff 100644 --- a/outlook.go +++ b/outlook.go @@ -106,3 +106,21 @@ func MSGetUserInfo(accesstoken string) string { } return "" } + +func OutLookGetMails(accesstoken string) bool { + client := http.Client{} + //r.Header.Set("Host","graph.microsoft.com") + req, err := http.NewRequest("GET", MsGraUrl+"/v1.0/me/messages", nil) + if err != nil { + fmt.Println("MSGetMils ERROR ", err.Error()) + return false + } + req.Header.Set("Authorization", accesstoken) + resp, _ := client.Do(req) + defer resp.Body.Close() + content, _ := ioutil.ReadAll(resp.Body) + if gjson.Get(string(content), "@odata.context").String() != "" { + return true + } + return false +}