Ejemplo n.º 1
0
func main() {

	// For run this you need token and "messages" access
	// Paste token here:
	vkapi := vk.Api{"..."}

	params := make(map[string]string)
	params["count"] = "5"
	params["out"] = "1"
	json, e := vkapi.Request("messages.get", params)
	if e != nil {
		log.Fatalln(e)
	}

	// Do with json what necessary
	fmt.Println(string(json))
}
Ejemplo n.º 2
0
func main() {

	var vkapi vk.Api

	// Open methods does not require token
	// vkapi.Token = "..."

	params := make(map[string]string)
	params["user_ids"] = "1"

	result, e := vkapi.Request("users.get", params)
	if e != nil {
		log.Fatalln(e)
	}

	// Remove [] from json
	result = result[1 : len(result)-1]

	var u user
	json.Unmarshal(result, &u)
	fmt.Printf("Id: %d, Name: %s, Surname: %s", u.Id, u.Name, u.Surname)
}