foaf

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 5 Imported by: 0

README

FOAF

Documentation

FOAF (акроним от Friend of a Friend - "друг друга") является машиночитаемым языком для описания людей, групп и отношений между ними.

VK имеет модифицированный FOAF, который был сделан по примеру яндекса + добавили свои теги(некоторых тегов нет в документации). К сожалению, документация яндекса потерялась во времени (archive).

Примеры

Получение пользователя

ctx := context.Background()

person, err := foaf.GetPerson(ctx, 1)
if err != nil {
  log.Fatal(err)
}

log.Println(person)
ctx := context.Background()

person, err := foaf.GetGroup(ctx, 1)
if err != nil {
  log.Fatal(err)
}

log.Println(person)

Получение пользователя, используя кастомный HTTP-клиент

ctx := context.Background()

// Use the custom HTTP client
httpClient := &http.Client{Timeout: 2 * time.Second}
ctx = context.WithValue(ctx, foaf.HTTPClient, httpClient)

person, err := foaf.GetPerson(ctx, 1)
if err != nil {
  log.Fatal(err)
}

log.Println(person)

Documentation

Overview

Package foaf wrapper for FOAF.

Specification https://web.archive.org/web/20140909053226/http://api.yandex.ru/blogs/doc/indexation/concepts/what-is-foaf.xml

Index

Examples

Constants

View Source
const (
	HTTPClient = internal.HTTPClientKey
	UserAgent  = internal.UserAgentKey
)

Context keys to use with https://golang.org/pkg/context WithValue function to associate.

View Source
const FOAFURL = "https://vk.com/foaf.php" // TODO: v2 rename (name starts with package name)

FOAFURL url foaf.

Variables

This section is empty.

Functions

This section is empty.

Types

type Access

type Access string

Access type.

const (
	AccessAllowed    Access = "allowed"
	AccessDisallowed Access = "disallowed"
)

Types of Access.

type Date

type Date struct {
	Date string `xml:"date,attr"`
}

Date may be used to express temporal information at any level of granularity.

Use time.Parse(time.RFC3339, v.Date).

type Edu

type Edu struct {
	School     School     `xml:"school"`
	University University `xml:"university"`
}

Edu struct.

type External

type External struct {
	Status   string `xml:"status,attr"`
	Resource string `xml:"resource,attr"`
}

External struct.

type Gender

type Gender string

Gender - the gender of this Agent (typically but not necessarily 'male' or 'female').

const (
	GenderMale   Gender = "male"
	GenderFemale Gender = "female"
)

Types of Gender.

type Group

type Group struct {
	GroupType    GroupType `xml:"groupType"`
	Name         string    `xml:"name"`
	URI          []URI     `xml:"URI"`
	Img          Img       `xml:"img"`
	Weblog       Weblog    `xml:"weblog"`
	MembersCount int       `xml:"membersCount"`
	StartDate    Date      `xml:"startDate"`
	FinishDate   Date      `xml:"finishDate"`
}

Group - A class of Agents.

http://xmlns.com/foaf/spec/#term_Group

func GetGroup

func GetGroup(ctx context.Context, groupID int) (Group, error)

GetGroup return Group.

Example
package main

import (
	"context"
	"log"

	"github.com/SevereCloud/vksdk/foaf"
)

func main() {
	ctx := context.Background()

	person, err := foaf.GetGroup(ctx, 1)
	if err != nil {
		log.Fatal(err)
	}

	log.Println(person)
}
Output:

type GroupType

type GroupType string

GroupType type.

const (
	GroupTypeGroup  GroupType = "group"
	GroupTypePublic GroupType = "public"
	GroupTypeEvent  GroupType = "event"
)

Types of GroupType.

type Image

type Image struct {
	Primary   string      `xml:"primary,attr"`
	Width     int         `xml:"width,attr"`
	Height    int         `xml:"height,attr"`
	About     string      `xml:"about,attr"`
	Thumbnail []Thumbnail `xml:"thumbnail"`
}

Image digital images (such as JPEG, PNG, GIF bitmaps, SVG diagrams etc.).

type Img

type Img struct {
	Image Image `xml:"Image"`
}

Img - An image that can be used to represent some thing (ie. those depictions which are particularly representative of something, eg. one's photo on a homepage).

type Job

type Job struct {
	WorkPlace WorkPlace `xml:"workPlace"`
	Military  Military  `xml:"military"`
}

Job struct.

type Location

type Location struct {
	Country string `xml:"country,attr"`
	City    string `xml:"city,attr"`
}

Location struct.

type Military

type Military struct {
	Title     string   `xml:"title,attr"`
	DateStart string   `xml:"dateStart,attr"`
	About     string   `xml:"about,attr"`
	Location  Location `xml:"location"`
}

Military struct.

type Person

type Person struct {
	PublicAccess      Access       `xml:"publicAccess"`
	ProfileState      ProfileState `xml:"profileState"`
	URI               []URI        `xml:"URI"`
	FirstName         string       `xml:"firstName"`
	SecondName        string       `xml:"secondName"`
	Name              string       `xml:"name"`
	Weblog            Weblog       `xml:"weblog"`
	Gender            string       `xml:"gender"`
	Created           Date         `xml:"created"`
	LastLoggedIn      Date         `xml:"lastLoggedIn"`
	Modified          Date         `xml:"modified"`
	SubscribersCount  int          `xml:"subscribersCount"`
	FriendsCount      int          `xml:"friendsCount"`
	SubscribedToCount int          `xml:"subscribedToCount"`
	Birthday          string       `xml:"birthday"`
	DateOfBirth       string       `xml:"dateOfBirth"`
	Img               Img          `xml:"img"`
	FamilyStatus      string       `xml:"familyStatus"`
	SkypeID           string       `xml:"skypeID"` // A Skype ID
	Homepage          string       `xml:"homepage"`
	Phone             []Phone      `xml:"phone"`
	ExternalProfile   []External   `xml:"externalProfile"`
	Interest          string       `xml:"interest"`
	LocationOfBirth   Location     `xml:"locationOfBirth"`
	Location          Location     `xml:"location"`
	Edu               []Edu        `xml:"edu"`
	Job               []Job        `xml:"job"`
}

Person - A person.

http://xmlns.com/foaf/spec/#term_Person

func GetPerson

func GetPerson(ctx context.Context, userID int) (Person, error)

GetPerson return Person.

Example
package main

import (
	"context"
	"log"

	"github.com/SevereCloud/vksdk/foaf"
)

func main() {
	ctx := context.Background()

	person, err := foaf.GetPerson(ctx, 1)
	if err != nil {
		log.Fatal(err)
	}

	log.Println(person)
}
Output:

Example (CustomHTTP)
package main

import (
	"context"
	"log"
	"net/http"
	"time"

	"github.com/SevereCloud/vksdk/foaf"
)

func main() {
	ctx := context.Background()

	// Use the custom HTTP client
	httpClient := &http.Client{Timeout: 2 * time.Second}
	ctx = context.WithValue(ctx, foaf.HTTPClient, httpClient)

	person, err := foaf.GetPerson(ctx, 1)
	if err != nil {
		log.Fatal(err)
	}

	log.Println(person)
}
Output:

type Phone

type Phone struct {
	Primary string `xml:"primary,attr"`
}

Phone struct.

type ProfileState

type ProfileState string

ProfileState is profile state.

const (
	ProfileStateDeleted     ProfileState = "deleted"
	ProfileStateVerified    ProfileState = "verified"
	ProfileStateActive      ProfileState = "active"
	ProfileStateBanned      ProfileState = "banned"
	ProfileStateDeactivated ProfileState = "deactivated"
)

Types of ProfileState.

type School

type School struct {
	Title      string   `xml:"title,attr"`
	DateStart  string   `xml:"dateStart,attr"`
	DateFinish string   `xml:"dateFinish,attr"`
	About      string   `xml:"about,attr"`
	Location   Location `xml:"location"`
}

School struct.

type Thumbnail

type Thumbnail struct {
	Width    int    `xml:"width,attr"`
	Height   int    `xml:"height,attr"`
	Resource string `xml:"resource,attr"`
}

Thumbnail a derived thumbnail image.

type URI

type URI struct {
	Primary  string `xml:"primary,attr"`
	Resource string `xml:"resource,attr"`
}

URI struct.

type University

type University struct {
	Title        string   `xml:"title,attr"`
	ShortCaption string   `xml:"shortCaption,attr"`
	DateFinish   string   `xml:"dateFinish,attr"`
	About        string   `xml:"about,attr"`
	Location     Location `xml:"location"`
}

University struct.

type Weblog

type Weblog struct {
	Title    string `xml:"title,attr"`
	Resource string `xml:"resource,attr"`
}

Weblog struct.

type WorkPlace

type WorkPlace struct {
	Title     string   `xml:"title,attr"`
	About     string   `xml:"about,attr"`
	DateStart string   `xml:"dateStart,attr"`
	Position  string   `xml:"position,attr"`
	Location  Location `xml:"location"`
}

WorkPlace struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL