Add OutLookGetMails Func

This commit is contained in:
iyear 2020-03-27 16:31:09 +08:00
parent 43ea9c2fb4
commit c8015361f9

View File

@ -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
}