【调度系统】广东民航医疗快线调度系统源代码
wanglizhong
2025-05-05 8a7dab004bc3eca7808d0cc196a329464402bbc9
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
 
namespace Aliyun\Core;
 
abstract class RpcAcsRequest extends AcsRequest
{
    private $dateTimeFormat = 'Y-m-d\TH:i:s\Z'; 
    private $domainParameters = array();
    
    function  __construct($product, $version, $actionName)
    {
        parent::__construct($product, $version, $actionName);
        $this->initialize();
    }
    
    private function initialize()
    {
        $this->setMethod("GET");    
        $this->setAcceptFormat("JSON");
    }
    
 
    private function prepareValue($value)
    {
        if (is_bool($value)) {
            if ($value) {
                return "true";
            } else {
                return "false";
            }
        } else {
            return $value;
        }
    }
 
    public function composeUrl($iSigner, $credential, $domain)
    {
        $apiParams = parent::getQueryParameters();
        foreach ($apiParams as $key => $value) {
            $apiParams[$key] = $this->prepareValue($value);
        }
        $apiParams["RegionId"] = $this->getRegionId();
        $apiParams["AccessKeyId"] = $credential->getAccessKeyId();
        $apiParams["Format"] = $this->getAcceptFormat();
        $apiParams["SignatureMethod"] = $iSigner->getSignatureMethod();
        $apiParams["SignatureVersion"] = $iSigner->getSignatureVersion();
        $apiParams["SignatureNonce"] = md5(uniqid(mt_rand(), true));
        $apiParams["Timestamp"] = gmdate($this->dateTimeFormat);
        $apiParams["Action"] = $this->getActionName();
        $apiParams["Version"] = $this->getVersion();
        $apiParams["Signature"] = $this->computeSignature($apiParams, $credential->getAccessSecret(), $iSigner);
        if(parent::getMethod() == "POST") {
            
            $requestUrl = $this->getProtocol()."://". $domain . "/";            
            foreach ($apiParams as $apiParamKey => $apiParamValue)
            {
                $this->putDomainParameters($apiParamKey,$apiParamValue);
            }
            return $requestUrl;
        }
        else {    
            $requestUrl = $this->getProtocol()."://". $domain . "/?";
 
            foreach ($apiParams as $apiParamKey => $apiParamValue)
            {
                $requestUrl .= "$apiParamKey=" . urlencode($apiParamValue) . "&";
            }
            return substr($requestUrl, 0, -1);
        }
    }
    
    private function computeSignature($parameters, $accessKeySecret, $iSigner)
    {
        ksort($parameters);
        $canonicalizedQueryString = '';
        foreach($parameters as $key => $value)
        {
            $canonicalizedQueryString .= '&' . $this->percentEncode($key). '=' . $this->percentEncode($value);
        }
        $stringToSign = parent::getMethod().'&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1));
        $signature = $iSigner->signString($stringToSign, $accessKeySecret."&");
 
        return $signature;
    }
    
    protected function percentEncode($str)
    {
        $res = urlencode($str);
        $res = preg_replace('/\+/', '%20', $res);
        $res = preg_replace('/\*/', '%2A', $res);
        $res = preg_replace('/%7E/', '~', $res);
        return $res;
    }
    
    public function getDomainParameter()    
    {
        return $this->domainParameters;
    }
    
    public function putDomainParameters($name, $value)
    {
        $this->domainParameters[$name] = $value;
    }
    
}