@@ 74-100 (lines=27) @@ | ||
71 | * |
|
72 | * @return mixed |
|
73 | */ |
|
74 | public function curl_post($url, $data, $header, $post = 1) |
|
75 | { |
|
76 | //初始化curl |
|
77 | $ch = curl_init(); |
|
78 | //参数设置 |
|
79 | $res = curl_setopt($ch, CURLOPT_URL, $url); |
|
80 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|
81 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
82 | curl_setopt($ch, CURLOPT_HEADER, 0); |
|
83 | curl_setopt($ch, CURLOPT_POST, $post); |
|
84 | if ($post) { |
|
85 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); |
|
86 | } |
|
87 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
88 | curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|
89 | $result = curl_exec($ch); |
|
90 | //连接失败 |
|
91 | if ($result === false) { |
|
92 | if ($this->BodyType === 'json') { |
|
93 | $result = '{"statusCode":"172001","statusMsg":"网络错误"}'; |
|
94 | } else { |
|
95 | $result = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Response><statusCode>172001</statusCode><statusMsg>网络错误</statusMsg></Response>'; |
|
96 | } |
|
97 | } |
|
98 | curl_close($ch); |
|
99 | ||
100 | return $result; |
|
101 | } |
|
102 | ||
103 | /** |
@@ 30-56 (lines=27) @@ | ||
27 | * |
|
28 | * @return string |
|
29 | */ |
|
30 | public function curl_post($url, $data, $header, $post = 1) |
|
31 | { |
|
32 | //初始化curl |
|
33 | $ch = curl_init(); |
|
34 | //参数设置 |
|
35 | $res = curl_setopt($ch, CURLOPT_URL, $url); |
|
36 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|
37 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
38 | curl_setopt($ch, CURLOPT_HEADER, 0); |
|
39 | curl_setopt($ch, CURLOPT_POST, $post); |
|
40 | if ($post) { |
|
41 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); |
|
42 | } |
|
43 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
44 | curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|
45 | $result = curl_exec($ch); |
|
46 | //连接失败 |
|
47 | if ($result === false) { |
|
48 | if ($this->BodyType === 'json') { |
|
49 | $result = '{"statusCode":"172001","statusMsg":"网络错误"}'; |
|
50 | } else { |
|
51 | $result = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Response><statusCode>172001</statusCode><statusMsg>网络错误</statusMsg></Response>'; |
|
52 | } |
|
53 | } |
|
54 | curl_close($ch); |
|
55 | ||
56 | return $result; |
|
57 | } |
|
58 | } |
|
59 |