$p) { $arr[] = '#' . $k . '#=' . urlencode($p); } $str = implode('&', $arr); $data = array('tpl_id' => $tplId, 'tpl_value' => $str, 'apikey' => YP_SMS_KEY, 'mobile' => $mobiles); // return self::tplSend($data); $result = curlInit(YP_TPLS_URL, $data, 'Post'); if ($result !== false) { $result = json_decode($result, true); /*liujuan 错误原因*/ $reason=""; if (isset($result['data'][0]['msg'])) { $reason=$result['data'][0]['msg']; } if (isset($result['total_fee'])) { /*liujuan total_fee>0.0000才是发送成功*/ if ($result['total_fee']>0.0000) { $result['IS_SUCCESS'] = 1; }else{ $result['IS_SUCCESS'] = 0; $result['reason']=$reason; } //原版 $result['IS_SUCCESS'] = 1; } else { $result['IS_SUCCESS'] = 0; /*liujuan 报错原因*/ $result['reason']="服务端错误"; } } return $result; } /** * [sendBillCode 钱多多发送验证码接口] * @Author mzb * @DateTime 2018-04-02T14:07:06+0800 * @param [type] $phone [description] * @param integer $type [description] * @return [type] [description] */ public static function sendCode($tplId, $mobile, $parameter, $type = 1) { $parameter = json_decode($parameter, true); if ($type == 1) { $arr = []; foreach ($parameter as $k => $p) { $arr[] = '#' . $k . '#=' . urlencode($p); } $str = implode('&', $arr); $data = array('tpl_id' => $tplId, 'tpl_value' => $str, 'apikey' => YP_SMS_KEY, 'mobile' => $mobile); // return self::tplSend($data); $result = curlInit(YP_TPL_URL, $data, 'Post'); } else if ($type == 2) { if (!isset($parameter['code'])) { return false; } $code = $parameter['code']; $data = array('code' => $code, 'apikey' => YP_SMS_KEY, 'mobile' => $mobile); $result = curlInit(YP_VOICE_URL, $data, 'Post'); } if ($result == false) { return false; } $result = json_decode($result, true); if (isset($result['fee'])) { $result['IS_SUCCESS'] = 1; } else { $result['IS_SUCCESS'] = 0; $result['reason']="服务端错误"; } return $result; } }