电子合同API开发文档 v5

获取支付宝授权认证地址

请求地址:/v5/Certification/aliPayAuthorization.json

请求方式:POST

接口版本: 5.2.3

接口描述:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
*
* 推荐尽量使用POST方式
* sdk接口都均以https方式调用,客户端需要验证服务器证书是否正常。
* cacert.pem为可信任根证书文件。用户请保持更新
*/
package APIStore
 
import (
    "fmt"
    "io/ioutil"
    "math/rand"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)
 
//post访问方式(推荐)
//host 请求地址
//param 附加参数
func RequestPost(host string, param string) {
    body := ioutil.NopCloser(strings.NewReader(param))
    req, err := http.NewRequest("POST", host, body)
    if err != nil {
        fmt.Println("Fatal error ", err.Error())
        os.Exit(0)
    }
    req.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
    req.Header.Add("Accept-Encoding", "UTF-8")
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") //这个一定要加,不加form的值post不过去
    //fmt.Printf("%+v\n", req)      //看下发送的结构
 
    client := &http.Client{}
    resp, err := client.Do(req) //发送
    if err != nil {
        fmt.Println("error:", err)
        return
    }
    defer resp.Body.Close() //一定要关闭resp.Body
    data, err := ioutil.ReadAll(resp.Body)
}
 
//get方式请求
//host 请求地址
//param 附加参数
func RequestGet(host string, param string) {
    req, err := http.NewRequest("GET", host+"?"+param, nil)
    if err != nil {
        fmt.Println("Fatal error ", err.Error())
        os.Exit(0)
    }
    req.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
    req.Header.Add("Accept-Encoding", "UTF-8")
    //fmt.Printf("%+v\n", req)      //看下发送的结构
 
    client := &http.Client{}
    resp, err := client.Do(req) //发送
    if err != nil {
        fmt.Println("error:", err)
        return
    }
    defer resp.Body.Close() //一定要关闭resp.Body
    data, err := ioutil.ReadAll(resp.Body)
}
 
//获取内容
func getContent(requestType string) {
     var url string="https://api-v2.1dq.com/v5/Certification/aliPayAuthorization.json";
   var param string ="easy_id=175592531139104768&color=000000&redirect_url=";
 
    if requestType == "GET" {
        RequestGet(url, param)
    } else {
        RequestPost(url, param)
    }
 
}
 
}