Rufus Deponian лет назад: 5
Родитель
Сommit
8b12d6bcda
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      sdApi1/sdApi1.go

+ 14 - 0
sdApi1/sdApi1.go

@@ -32,6 +32,20 @@ func GetUnits() (models.Units, error) {
 	return units, nil
 }
 
+func GetPeople() (models.People, error) {
+	var people models.People
+	buf, err := getJSON("https://sd.mephi.ru/api/1/faces.json")
+	if err != nil {
+		return nil, err
+	}
+
+	if err := json.Unmarshal(buf.Bytes(), &people); err != nil {
+		return nil, fmt.Errorf("Cannot parse: %v: \"%v\"", string(buf.Bytes()), err.Error())
+	}
+
+	return people, nil
+}
+
 func getJSON(url string) (*bytes.Buffer, error) {
 	client := &http.Client{}