Пример #1
0
func GetMyDetails(w http.ResponseWriter, req *http.Request) (response []byte) {
	fmt.Println("Getting My Details")
	params := url.Values{}
	params.Set("fields", "id,name")
	params.Set("access_token", AccessToken)
	return utils.ProcessRequest("GET", "", GraphApiUrl+"/me?"+params.Encode(), nil)
}
Пример #2
0
func SignIn(w http.ResponseWriter, req *http.Request) {
	fmt.Println("Trying to Auth Twitter")
	// Preparing Params
	params := GetHeadersMap()
	params.Set("oauth_callback", redirect_uri)
	method := "POST"
	endUrl := "/oauth/request_token"
	header := PrepareOAuthHeaders(method, endUrl, params)
	oauth_token_response := string(utils.ProcessRequest(method, header, ApiUrl+endUrl, nil))
	fmt.Println(oauth_token_response)
	if strings.Contains(oauth_token_response, "oauth_token") {
		AccessToken = strings.Split(strings.Split(oauth_token_response, "&")[0], "=")[1]
		fmt.Println(string(utils.ProcessRequest("GET", "", ApiUrl+"/oauth/authenticate?oauth_token="+utils.Encode(AccessToken, false), nil))) // TODO: Replace this with LOGIN Page
	} else {
		fmt.Println(oauth_token_response)
	}
}
Пример #3
0
func (r *Facebook) Post(status string) {
	fmt.Println("Post Added in Facebook Stream, " + facebook.AccessToken)
	params := url.Values{}
	params.Set("message", status)
	params.Set("access_token", facebook.AccessToken)
	response := utils.ProcessRequest("POST", "", facebook.GraphApiUrl+"/me/feed?"+params.Encode(), nil)
	fmt.Println(string(response))
}
Пример #4
0
func Auth(w http.ResponseWriter, req *http.Request) (response []byte) {
	fmt.Println("Trying to Auth Instagram")
	params := url.Values{}
	params.Set("client_id", Client_id)
	params.Set("redirect_uri", Redirect_uri)
	params.Set("response_type", "code")
	return utils.ProcessRequest("POST", "", ApiUrl+"/oauth/authorize?"+params.Encode(), nil)
}
Пример #5
0
func ConfirmIdentity(w http.ResponseWriter, req *http.Request, code string) (response []byte) {
	fmt.Println("Confirming Identity with FB")
	params := url.Values{}
	params.Set("client_id", client_id)
	params.Set("redirect_uri", redirect_uri)
	params.Set("client_secret", client_secret)
	params.Set("code", code)
	return utils.ProcessRequest("GET", "", GraphApiUrl+"/v2.3/oauth/access_token?"+params.Encode(), nil)
}
Пример #6
0
func Auth(w http.ResponseWriter, req *http.Request) (response []byte) {
	fmt.Println("Trying to Auth Facebook")
	params := url.Values{}
	params.Set("client_id", client_id)
	params.Set("redirect_uri", redirect_uri)
	params.Set("scope", "user_about_me,user_friends,user_likes,user_posts,user_events,user_status,publish_actions")
	params.Set("display", "page")
	return utils.ProcessRequest("POST", "", GraphApiUrl+"/oauth/authorize?"+params.Encode(), nil)
}
Пример #7
0
func (r *Instagram) Post(status string) {
	fmt.Println("Post Added in Instagram Stream")
	endUrl := "/v1/users/self/follows"
	form := url.Values{}
	form.Set("access_token", instagram.AccessToken)
	//form.Set("count", "2")
	form.Set("sig", instagram.CreateSignature(form, endUrl))
	jsonOut := utils.GetJson(utils.ProcessRequest("GET", "", instagram.ApiUrl+endUrl+"?"+form.Encode(), nil))
	fmt.Println(jsonOut)
}
Пример #8
0
func postTweet(status string) {
	fmt.Println("Post Added in Twitter Stream " + twitter.AccessToken)
	params := twitter.GetHeadersMap()
	params.Set("status", status)
	method := "POST"
	endUrl := "/1.1/statuses/update.json"
	header := twitter.PrepareOAuthHeaders(method, endUrl, params)
	response := utils.ProcessRequest(method, header, twitter.ApiUrl+endUrl+"?status="+utils.Encode(status, false), nil)
	fmt.Println(string(response))
}
Пример #9
0
func listTweets() {
	fmt.Println("List of Tweets " + twitter.AccessToken)
	params := twitter.GetHeadersMap()
	params.Set("screen_name", twitter.ScreenName)
	params.Set("count", "2")
	method := "GET"
	endUrl := "/1.1/statuses/user_timeline.json"
	header := twitter.PrepareOAuthHeaders(method, endUrl, params)
	params = url.Values{}
	params.Set("screen_name", twitter.ScreenName)
	params.Set("count", "2")
	response := utils.ProcessRequest(method, header, twitter.ApiUrl+endUrl+"?"+params.Encode(), nil)
	fmt.Println(string(response))
}
Пример #10
0
func ReIssueAccessToken(oauth_verifier string) {
	fmt.Println("Re-Issuing the Access Token ....")
	// Preparing Params
	params := GetHeadersMap()
	method := "POST"
	endUrl := "/oauth/access_token"
	header := PrepareOAuthHeaders(method, endUrl, params)
	fmt.Println(header)
	params = url.Values{}
	params.Set("oauth_verifier", oauth_verifier)
	oauth_token_response := string(utils.ProcessRequest(method, header, ApiUrl+endUrl+"?"+params.Encode(), nil))
	if strings.Contains(oauth_token_response, "oauth_token") {
		AccessToken = strings.Split(strings.Split(oauth_token_response, "&")[0], "=")[1]
		AccessTokenSecret = strings.Split(strings.Split(oauth_token_response, "&")[1], "=")[1]
		UserID = strings.Split(strings.Split(oauth_token_response, "&")[2], "=")[1]
		ScreenName = strings.Split(strings.Split(oauth_token_response, "&")[3], "=")[1]
		// Write Everything to JSON
		jsonOut := map[string]string{"access_token": AccessToken, "oauth_token_secret": AccessTokenSecret, "user_id": UserID, "screen_name": ScreenName}
		utils.WriteJsonToFile(jsonOut, AccessTokenFile)
	}
}