修复post方式为x-www-form-urlencodedd方式
Code Review By Rock Zhang
Showing
1 changed file
with
10 additions
and
1 deletions
@@ -212,7 +212,16 @@ class Yohobuy | @@ -212,7 +212,16 @@ class Yohobuy | ||
212 | unset($data['private_key']); | 212 | unset($data['private_key']); |
213 | } | 213 | } |
214 | if (!empty($data)) { | 214 | if (!empty($data)) { |
215 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | 215 | + // 新加支持application/x-www-form-urlencoded调用方式 |
216 | + $str = ''; | ||
217 | + foreach ($data as $key => $val) { | ||
218 | + $str .= $key . '=' . $val . '&'; | ||
219 | + } | ||
220 | + | ||
221 | + $str = rtrim($str, '&'); | ||
222 | + | ||
223 | +// curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | ||
224 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $str); | ||
216 | } | 225 | } |
217 | $result = curl_exec($ch); | 226 | $result = curl_exec($ch); |
218 | if (!$returnJson && !empty($result)) { | 227 | if (!$returnJson && !empty($result)) { |
-
Please register or login to post a comment