facebook

package module
v0.0.0-...-10fec9b Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 License: MIT Imports: 7 Imported by: 6 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Facebook Go SDK

v0.2.0

Facebook Go SDK is an unofficial Facebook SDK for Golang. It is very simple and easy to use.

HOW-TO

The easiest way to get started is by following the guide that I have wrote on the wiki section.

WIKI

ROADMAP

Please refer to Projects tab for more detail.

RELEASE

v0.2.0

  • Added a feature to share url

AUTHOR

Faris

LICENSE

Release under MIT LICENSE

Documentation

Overview

Package facebook implements methods for saving developer when they want to use Facebook Graph API using Golang

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	FB   *Facebook
	Path string

	SelectedFields string
	Message        string
	ShareURL       string
}

API contains information that can be passed to access facebook graph api

func (*API) Delete

func (a *API) Delete() (interface{}, error)

Delete is use to submit request using DELETE method

func (*API) Fields

func (a *API) Fields(fields string) APIInterface

Fields is use to set selected fields to be return by facebook graph api

func (*API) Get

func (a *API) Get() (interface{}, error)

Get is use to submit request using GET method

func (a *API) Link(shareURL string) APIInterface

Link is use to define a share link that want to be posted into user's timeline

func (*API) Messages

func (a *API) Messages(msg string) APIInterface

Messages is use to define message that want to be posted into user's timeline

func (*API) Post

func (a *API) Post() (interface{}, error)

Post is use to submit request using POST method

type APIInterface

type APIInterface interface {
	Fields(fields string) APIInterface
	Messages(msg string) APIInterface
	Link(shareURL string) APIInterface

	Get() (interface{}, error)
	Post() (interface{}, error)
	Delete() (interface{}, error)
}

APIInterface is the main functionality of facebook-go-sdk

type Call

type Call struct {
	HTTPClient  http.Client
	HTTPRequest *http.Request
	HTTPHeader  map[string]string
	Method      string
	URL         string
	Body        io.Reader
}

Call is a place where Facebook Graph API are being called. This is the HIT-man!

func (*Call) AddHeader

func (c *Call) AddHeader(key string, value string) CallInterface

AddHeader is use to add request header

func (*Call) New

func (c *Call) New() CallInterface

New is use to initialize the Call methods

func (*Call) SetBody

func (c *Call) SetBody(body io.Reader) CallInterface

SetBody is use to set the request body

func (*Call) SetMethod

func (c *Call) SetMethod(method string) CallInterface

SetMethod is use to set the http method

func (*Call) SetURL

func (c *Call) SetURL(url string) CallInterface

SetURL is use to set the target URL

func (*Call) Submit

func (c *Call) Submit() (interface{}, error)

Submit is where the target URL is being called

type CallInterface

type CallInterface interface {
	New() CallInterface

	SetMethod(method string) CallInterface
	SetURL(url string) CallInterface
	SetBody(body io.Reader) CallInterface
	AddHeader(key string, value string) CallInterface

	Submit() (interface{}, error)
}

CallInterface contains the common method to be setup before submitting request to facebook graph api

type Facebook

type Facebook struct {
	AppID       string
	AppSecret   string
	Version     string
	AccessToken string
}

Facebook is the base schema

func (*Facebook) API

func (fb *Facebook) API(path string) APIInterface

API represents the Facebook Graph API that can be use by developers. It helps to simplify things

func (*Facebook) GenerateAccessToken

func (fb *Facebook) GenerateAccessToken(redirectURI string, code string) (map[string]interface{}, error)

GenerateAccessToken returns access_token data

func (*Facebook) GetAppID

func (fb *Facebook) GetAppID() string

GetAppID returns the current used app id

func (*Facebook) GetAppSecret

func (fb *Facebook) GetAppSecret() string

GetAppSecret returns the current used app secret

func (*Facebook) GetVersion

func (fb *Facebook) GetVersion() string

GetVersion returns the current used API version

func (*Facebook) Raw

func (fb *Facebook) Raw(method string, path string, queryStr string, body io.Reader) (interface{}, error)

Raw is use to call Facebook Graph API in raw method @method string e.g. `GET`, `POST` @path strin e.g. `/me` @queryStr string e.g. `?fields=id,name` @body io.Reader e.g. ... (optional)

func (*Facebook) SetAccessToken

func (fb *Facebook) SetAccessToken(accessToken string) Interface

SetAccessToken is use to set current access token

func (*Facebook) SetAppID

func (fb *Facebook) SetAppID(appID string) Interface

SetAppID is use to set your application id

func (*Facebook) SetAppSecret

func (fb *Facebook) SetAppSecret(appSecret string) Interface

SetAppSecret is use to set your application secret

func (*Facebook) SetVersion

func (fb *Facebook) SetVersion(version string) Interface

SetVersion is use to set the version of graph api

type Graph

type Graph struct {
	Version string
	URL     string
}

Graph represents a default configuration for facebook graph api

func (*Graph) GenerateRawURL

func (g *Graph) GenerateRawURL(path string, querystring string) string

GenerateRawURL is use to generate a URL with raw query string

func (*Graph) GenerateURL

func (g *Graph) GenerateURL(path string) string

GenerateURL is use to generate a URL to be used when requesting to Facebook Graph API

func (*Graph) GenerateURLWithFields

func (g *Graph) GenerateURLWithFields(path string, fields string) string

GenerateURLWithFields is use to generate a URL to be used when accessing Facebook Graph API with `fields` as query string

func (*Graph) GetGraphURL

func (g *Graph) GetGraphURL() string

GetGraphURL is use to get current graph API URL

func (*Graph) GetVersion

func (g *Graph) GetVersion() string

GetVersion is use to get current version used by graph functions

func (*Graph) SetVersion

func (g *Graph) SetVersion(version string) GraphInterface

SetVersion is use to set the Facebook Graph API version and also the default Graph API url

type GraphInterface

type GraphInterface interface {
	SetVersion(version string) GraphInterface
	GetVersion() string
	GetGraphURL() string

	GenerateURL(path string) string
	GenerateURLWithFields(path string, fields string) string
	GenerateRawURL(path string, querystring string) string
}

GraphInterface represents all methods for using Facebook Graph API

type Interface

type Interface interface {
	SetAppID(appID string) Interface
	SetAppSecret(appSecret string) Interface
	SetVersion(version string) Interface
	SetAccessToken(accessToken string) Interface

	GetVersion() string
	GetAppID() string
	GetAppSecret() string

	GenerateAccessToken(redirectURI string, code string) (map[string]interface{}, error)

	Raw(method string, path string, queryStr string, body io.Reader) (interface{}, error)
	API(path string) APIInterface
}

Interface is the map interface for facebook-go-sdk

func New

func New() Interface

New is use to initalize facebook-go-sdk

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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