get event URLs
This commit is contained in:
@@ -23,3 +23,6 @@ type ResourceType struct {
|
|||||||
Collection *struct{} `xml:"DAV: collection"`
|
Collection *struct{} `xml:"DAV: collection"`
|
||||||
Calendar *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar"`
|
Calendar *struct{} `xml:"urn:ietf:params:xml:ns:caldav calendar"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CalandarData struct {
|
||||||
|
}
|
||||||
|
|||||||
+26
-7
@@ -26,9 +26,14 @@ func init_dav_client() {
|
|||||||
client = &http.Client{}
|
client = &http.Client{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Event struct {
|
||||||
|
Link string
|
||||||
|
}
|
||||||
|
|
||||||
type Calandar struct {
|
type Calandar struct {
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Link string
|
Link string
|
||||||
|
Events []Event
|
||||||
}
|
}
|
||||||
|
|
||||||
type SimpleCalDavData struct {
|
type SimpleCalDavData struct {
|
||||||
@@ -90,16 +95,19 @@ const XML_cal string = `
|
|||||||
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
<D:prop>
|
<D:prop>
|
||||||
<D:getetag/>
|
<D:getetag/>
|
||||||
<C:calendar-data/>
|
|
||||||
</D:prop>
|
</D:prop>
|
||||||
<C:filter>
|
|
||||||
<C:comp-filter name="VCALENDAR">
|
|
||||||
<C:comp-filter name="VEVENT"/>
|
|
||||||
</C:comp-filter>
|
|
||||||
</C:filter>
|
|
||||||
</C:calendar-query>
|
</C:calendar-query>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
// <C:calendar-data/>
|
||||||
|
|
||||||
|
// <C:filter>
|
||||||
|
// <C:comp-filter name="VCALENDAR">
|
||||||
|
// <C:comp-filter name="VEVENT"/>
|
||||||
|
// </C:comp-filter>
|
||||||
|
// </C:filter>
|
||||||
|
|
||||||
func get_calandar_data(cal Calandar, username string, password string) Calandar {
|
func get_calandar_data(cal Calandar, username string, password string) Calandar {
|
||||||
req, _ := http.NewRequest(
|
req, _ := http.NewRequest(
|
||||||
"REPORT",
|
"REPORT",
|
||||||
@@ -122,7 +130,18 @@ func get_calandar_data(cal Calandar, username string, password string) Calandar
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(body))
|
var davResp MultiStatus
|
||||||
|
err = xml.Unmarshal(body, &davResp)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range len(davResp.Responses) {
|
||||||
|
newEvent := Event{
|
||||||
|
Link: serverConfig.URL + davResp.Responses[i].Href,
|
||||||
|
}
|
||||||
|
cal.Events = append(cal.Events, newEvent)
|
||||||
|
}
|
||||||
|
|
||||||
return cal
|
return cal
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -12,8 +12,10 @@ func main() {
|
|||||||
fmt.Printf("Users display name: %s\n", calDavData.DisplayName)
|
fmt.Printf("Users display name: %s\n", calDavData.DisplayName)
|
||||||
fmt.Printf("Calandar Count: %d\n", len(calDavData.Calandars))
|
fmt.Printf("Calandar Count: %d\n", len(calDavData.Calandars))
|
||||||
for i := range len(calDavData.Calandars) {
|
for i := range len(calDavData.Calandars) {
|
||||||
|
calDavData.Calandars[i] = get_calandar_data(calDavData.Calandars[i], serverConfig.Username, serverConfig.Password)
|
||||||
|
|
||||||
fmt.Printf("Cal %d is named %s\n", i, calDavData.Calandars[i].DisplayName)
|
fmt.Printf("Cal %d is named %s\n", i, calDavData.Calandars[i].DisplayName)
|
||||||
fmt.Printf("\tLink to cal: %s\n", calDavData.Calandars[i].Link)
|
fmt.Printf("\tLink to cal: %s\n", calDavData.Calandars[i].Link)
|
||||||
calDavData.Calandars[i] = get_calandar_data(calDavData.Calandars[i], serverConfig.Username, serverConfig.Password)
|
fmt.Printf("\tEvent count: %d\n", len(calDavData.Calandars[i].Events))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user