Skip to content

Commit

Permalink
增加获取TOKEN的过程
Browse files Browse the repository at this point in the history
  • Loading branch information
HilerChen committed Oct 19, 2013
1 parent 0665e34 commit ba833d6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/caizi/controllers/authCall.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package controllers
import (
"fmt"
"io/ioutil"

"net/http"
"io"
"os"
"time"
"strconv"
)

type AuthCallController struct {
Expand All @@ -15,7 +21,17 @@ func (this *AuthCallController) Get() {
this.Layout = "layout.tpl"
this.TplNames = "index.tpl"

ioutil.WriteFile("authCallGet.txt", []byte(this.Input().Encode()), 777)
strTime := strconv.Itoa(time.Now().Nanosecond())
ioutil.WriteFile("authCallGet"+strTime+".txt", []byte(this.Input().Encode()), 777)

resp, err := http.Get("https://api.weibo.com/oauth2/access_token?client_id=933700690&client_secret=efc078042a83681339b3a074ebf96854&grant_type=authorization_code&redirect_uri=http://caizi.org/auth/callback&code=" + this.Input().Get("code"))

if err == nil {
file, _ := os.Create("token"+strTime+".txt")
defer file.Close()

io.Copy(file, resp.Body)
}
}

func (this *AuthCallController) Post() {
Expand Down

0 comments on commit ba833d6

Please sign in to comment.