示例#1
0
func main() {
	var cfg Config
	cfg.Load("./treehole.conf")

	status := "hello"
	params := map[string]string{
		"page_id": cfg.PageId,
		"status":  status,
	}
	err := renren.Do("pages.setStatus", params)
	if err != nil {
		log.Println(err)
		return
	}
	log.Println("successfully!!!")
}
示例#2
0
func onReceiveText(w http.ResponseWriter, r weixin.RequestMessage) {
	params := map[string]string{
		"page_id": cfg.PageId,
		"status":  (r.Content + cfg.Suffix),
	}
	err := renren.Do("pages.setStatus", params)

	// 微信
	content := "已经发送到人人主页:" + cfg.RenrenPageUrl
	if err != nil {
		content = "发送到人人主页失败了:" + err.Error()
	}

	tmpl := `<xml>
    <ToUserName><![CDATA[%s]]></ToUserName>
    <FromUserName><![CDATA[%s]]></FromUserName>
    <CreateTime>%d</CreateTime>
    <MsgType><![CDATA[text]]></MsgType>
    <Content><![CDATA[%s]]></Content>
    <FuncFlag>0</FuncFlag>
    </xml>`
	respStr := fmt.Sprintf(tmpl, r.FromUserName, r.ToUserName, time.Now().Unix(), content)
	fmt.Fprintf(w, "%s", respStr)
}