func GetConfig() *oauth2.Config {
	return &oauth2.Config{
		ClientID:     config.GetConfig().Google.ClientID,     // change this to yours
		ClientSecret: config.GetConfig().Google.ClientSecret, //change this to yours
		RedirectURL:  config.GetConfig().Google.RedirectURL,  // change this to your webserver adddress
		Scopes:       []string{goauth2.PlusLoginScope, goauth2.PlusMeScope, goauth2.UserinfoEmailScope, goauth2.UserinfoProfileScope},
		Endpoint:     google.Endpoint,
	}
}
func GetConfig() *oauth2.Config {
	return &oauth2.Config{
		ClientID:     config.GetConfig().Linkedin.ClientID,     // change this to yours
		ClientSecret: config.GetConfig().Linkedin.ClientSecret, //change this to yours
		RedirectURL:  config.GetConfig().Linkedin.RedirectURL,  // change this to your webserver adddress
		Scopes:       []string{"r_basicprofile", "r_emailaddress"},
		Endpoint:     linkedin.Endpoint,
	}
}
func GetConfig() *oauth2.Config {
	return &oauth2.Config{
		ClientID:     config.GetConfig().Facebook.ClientID,     // change this to yours
		ClientSecret: config.GetConfig().Facebook.ClientSecret, //change this to yours
		RedirectURL:  config.GetConfig().Facebook.RedirectURL,  // change this to your webserver adddress
		Scopes:       []string{"email", "user_birthday", "user_location", "user_about_me"},
		Endpoint:     facebook.Endpoint,
	}
}
Exemple #4
0
func GetConfig() *oauth2.Config {
	return &oauth2.Config{
		ClientID:     config.GetConfig().Vk.ClientID,     // change this to yours
		ClientSecret: config.GetConfig().Vk.ClientSecret, //change this to yours
		RedirectURL:  config.GetConfig().Vk.RedirectURL,  // change this to your webserver adddress
		Scopes:       []string{"email"},
		Endpoint:     vk.Endpoint,
	}
}
func PostOnPage(w http.ResponseWriter, r *http.Request) {
	//see http://stackoverflow.com/questions/17197970/facebook-permanent-page-access-token
	//for info on obtaining upexpirable page access token
	//also https://developers.facebook.com/docs/graph-api/reference/v2.5/page/feed for api description

	token := &oauth2.Token{
		AccessToken: config.GetConfig().Facebook.Token, //page access token
	}
	client := GetConfig().Client(oauth2.NoContext, token)
	response, err := client.Post(
		fmt.Sprintf(
			"https://graph.facebook.com/v2.5/dengraphapitest/feed?access_token=%s&link=%s&name=%s&caption=%s&description=%s&message=%s",
			token.AccessToken,
			url.QueryEscape("http://google.com"),
			url.QueryEscape("Link Name"),
			url.QueryEscape("Link Caption"),
			url.QueryEscape("Link Description"),
			url.QueryEscape("Post message"),
			//add picture field for image link
		),
		"application/json",
		nil,
	)
	if err != nil {
		http.Error(w, err.Error(), 400)
		return
	}
	fmt.Fprintf(w, "Successfully posted, response: %+v\n", response)
	body, _ := ioutil.ReadAll(response.Body)
	response.Body.Close()
	fmt.Fprintf(w, "Body: %s\n", body)
}