/** * @param $mobile * @param $data * @return mixed * @throws AppException * @throws Exception */ static function send_by_tpl($mobile, $data) { if (!self::$apikey) { _throw("YUNPIN APIKEY IS NULL"); } $curl = new Curl(); try { $url = "http://yunpian.com/v1/sms/tpl_send.json"; $data['apikey'] = self::$apikey; $data['mobile'] = $mobile; $res = $curl->post($url, $data); $body = json_decode($res['body']); if ($body->code > 0) { _throw($body->msg . " " . $body->detail); } return $body; } catch (Exception $e) { throw new Exception($e->getMessage()); } }