59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
package aliyun
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
//"fmt"
|
|
)
|
|
|
|
type Company struct {
|
|
ApiCode string
|
|
Url string
|
|
}
|
|
|
|
func (this *Company) Init(apiCode string) {
|
|
//"06c6a07e89dd45c88de040ee1489eef7"
|
|
this.ApiCode = apiCode
|
|
this.Url = "https://api.81api.com"
|
|
}
|
|
|
|
// GetCompanyBaseInfo 获取企业基础信息
|
|
func (this *Company) GetCompanyBaseInfo(name string) (string, error) {
|
|
url := "/getCompanyBaseInfo/"
|
|
|
|
client := &http.Client{}
|
|
|
|
reqest, err := http.NewRequest("GET", this.Url+url+name+"/?isRaiseErrorCode=1", nil)
|
|
|
|
if err != nil {
|
|
fmt.Println("Fatal error ", err.Error())
|
|
return "", err
|
|
}
|
|
|
|
reqest.Header.Add("Authorization", "APPCODE "+this.ApiCode)
|
|
response, err := client.Do(reqest)
|
|
defer response.Body.Close()
|
|
|
|
if err != nil {
|
|
fmt.Println("Fatal error ", err.Error())
|
|
return "", err
|
|
}
|
|
|
|
body, err := ioutil.ReadAll(response.Body)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
fmt.Println(string(body))
|
|
|
|
return string(body), err
|
|
|
|
}
|
|
|
|
var DefaultCompany Company
|
|
|
|
func init() {
|
|
DefaultCompany = Company{}
|
|
}
|