作者 yangfu

fix

@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "crypto/sha1" 4 "crypto/sha1"
5 "encoding/hex" 5 "encoding/hex"
6 "encoding/json" 6 "encoding/json"
  7 + "fmt"
7 "io/ioutil" 8 "io/ioutil"
8 "math/rand" 9 "math/rand"
9 "net/http" 10 "net/http"
@@ -13,6 +14,19 @@ import ( @@ -13,6 +14,19 @@ import (
13 "time" 14 "time"
14 ) 15 )
15 16
  17 +
  18 +var DefaultImClient ImClient
  19 +
  20 +var ErrorFailCall = fmt.Errorf(" imclient call failed")
  21 +
  22 +func InitImClient(baseUrl ,appKey,appSecret string){
  23 + DefaultImClient = ImClient{
  24 + baseUrl:baseUrl,
  25 + appKey:appKey,
  26 + appSecret:appSecret,
  27 + }
  28 +}
  29 +
16 func buildCheckSum(appSecret string, nonce string, curTime string) string { 30 func buildCheckSum(appSecret string, nonce string, curTime string) string {
17 str := []byte(appSecret + nonce + curTime) 31 str := []byte(appSecret + nonce + curTime)
18 sh := sha1.New() 32 sh := sha1.New()