Ejemplo n.º 1
0
	"fmt"
	"net/http"
	"net/url"
	"os"
	"sonet/utils"
)

const (
	GraphApiUrl   = "https://graph.facebook.com"
	redirect_uri  = "http://localhost:8080/"
	client_id     = "" //APP_ID
	client_secret = "" //APP_SECRET
)

var AccessToken string
var AccessTokenFile = utils.GetHomeDir() + "/.fb_access_token"

func CheckLoginStatus() (status bool) {
	if _, err := os.Stat(AccessTokenFile); err == nil {
		AccessToken, err = utils.ReadFromFile(AccessTokenFile)
		if err != nil {
			return false
		}
	} else {
		return false
	}
	return true
}

func GetMyDetails(w http.ResponseWriter, req *http.Request) (response []byte) {
	fmt.Println("Getting My Details")
Ejemplo n.º 2
0
	"os"
	"sonet/utils"
	"sort"
	"strconv"
	"strings"
	"time"
)

const (
	ApiUrl        = "https://api.twitter.com"
	client_id     = "" // CONSUMER_KEY
	client_secret = "" // CONSUMER_SECRET
	redirect_uri  = "http://127.0.0.1:8080/oauth2callback"
)

var AccessTokenFile = utils.GetHomeDir() + "/.twitter_access_token"
var AccessToken string
var AccessTokenSecret string
var UserID string
var ScreenName string

func CheckLoginStatus() (status bool) {
	if _, err := os.Stat(AccessTokenFile); err == nil {
		data, e := utils.ReadBytesFromFile(AccessTokenFile)
		tokenJson := utils.GetJson(data)
		AccessToken = tokenJson.(map[string]interface{})["access_token"].(string)
		AccessTokenSecret = tokenJson.(map[string]interface{})["oauth_token_secret"].(string)
		UserID = tokenJson.(map[string]interface{})["user_id"].(string)
		ScreenName = tokenJson.(map[string]interface{})["screen_name"].(string)
		fmt.Println(AccessToken, AccessTokenSecret, UserID, ScreenName)
		if e != nil {