vk_api

package module
v0.0.0-...-ebdd433 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2015 License: BSD-3-Clause Imports: 10 Imported by: 4

README

Api client for VKontakte with login/pass authorization (hack) on Go (golang).

###Plus: masking client_id to the iPhone, Android, iPad, Windows Phone clients.

go (golang) api client for vk.com

###Get

    go get github.com/yanple/vk_api
    // and dependence
    go get github.com/PuerkitoBio/goquery

###Import

    @import "github.com/yanple/vk_api"

##How to use

###Login/pass auth

	var api vk_api.Api
	err := api.LoginAuth(
		"email/phone",
		"pass",
		"3087104", // client id
		"wall,offline", // scope (permissions)
	)
	if err != nil {
		panic(err)
	}

###OAuth (click "allow" on special vk page) See martini based example

###Make query to API

	params := make(map[string]string)
	params["domain"] = "yanple"
	params["count"] = "1"

	strResp, err := api.Request("wall.get", params)
    if err != nil {
        panic(err)
    }
    log.Println(strResp)

See example

All api methods on https://vk.com/dev/methods

###Client ids (Masking only for login/pass auth)

    // client_id = "28909846" # Vk application ID (Android) doesn't work.
	// client_id = "3502561"  # Vk application ID (Windows Phone)
	// client_id = "3087106"  # Vk application ID (iPhone)
	// client_id = "3682744"  # Vk application ID (iPad)
License

Vk_api by Yanple is BSD licensed

Documentation

Index

Constants

View Source
const API_METHOD_URL = "https://api.vk.com/method/"
View Source
const AUTH_HOST = "https://oauth.vk.com/authorize"
View Source
const AUTH_HOST_GET_TOKEN = "https://oauth.vk.com/access_token"

Variables

This section is empty.

Functions

func ParseResponseUrl

func ParseResponseUrl(responseUrl string) (string, string, string, error)

Types

type Api

type Api struct {
	AccessToken string
	UserId      int
	ExpiresIn   int
	// contains filtered or unexported fields
}

func (*Api) GetAuthUrl

func (vk *Api) GetAuthUrl(redirect_uri string, client_id string, scope string) (string, error)

func (*Api) LoginAuth

func (vk *Api) LoginAuth(email string, password string, client_id string, scope string) error

func (*Api) OAuth

func (vk *Api) OAuth(redirect_uri string, client_secret string, client_id string, code string) error

func (*Api) Request

func (vk *Api) Request(methodName string, params map[string]string) (string, error)

func (*Api) SetDebug

func (vk *Api) SetDebug(s bool)

type OAuthResponse

type OAuthResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	UserId      int    `json:"user_id"`

	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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