'16520929823', 'password' => strtoupper(md5('16520929823')), 'gwid' => 'geyjla16', 'mobile' => $phone, 'message' => $content, ]; $post_data2 = [ 'type' => 'send', 'username' => '16520929823', 'password' => strtoupper(md5('16520929823')), 'gwid' => '9e3cdfdd', 'mobile' => $phone, 'message' => $content, 'rece' => 'json', ]; //// $post_data = "sname=dlycwl01&spwd=ycwl123456&scorpid=&sprdid=1012818&sdst=" . $phone . "&smsg=" . rawurlencode($content); // $post_data = "?username=16520929823&password=" . strtoupper(md5('6520929823')) . "&gwid=c2i00vx1&mobile=" . $phone . "&message=" . $content; // $gets = self::post($post_data, $target); // var_dump($target . $post_data); if ($template == 'EXTRACT_FAIL' || $template == 'EXTRACT' || $template == 'RECHARGE' || $template == 'SUCCESS_TRADE' || $template == 'END_TRADE' || $template == 'START_TRADE') $gets = do_request($target, $post_data); else { $gets = do_request($target2, $post_data2); } // var_dump($gets); @file_put_contents('sms.log', json_encode($gets), FILE_APPEND); if (substr($gets, 0, 7) == 'success' || json_decode($gets)['returnstatus'] == 'success') { return ['status' => 200, 'msg' => '短信发送成功']; } else { return ['status' => 400, 'msg' => '发送失败' . $gets]; } } // //第三方短信平台 // private static function post($data, $target) // { // $url_info = parse_url($target); // $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n"; // $httpheader .= "Host:" . $url_info['host'] . "\r\n"; // $httpheader .= "Content-Type:application/x-www-form-urlencoded\r\n"; // $httpheader .= "Content-Length:" . strlen($data) . "\r\n"; // $httpheader .= "Connection:close\r\n\r\n"; // //$httpheader .= "Connection:Keep-Alive\r\n\r\n"; // $httpheader .= $data; // // $fd = fsockopen($url_info['host'], 80); // fwrite($fd, $httpheader); // $gets = ""; // while (!feof($fd)) { // $gets .= fread($fd, 128); // } // fclose($fd); // if ($gets != '') { // $start = strpos($gets, ' 0) { // $gets = substr($gets, $start); // } // } // return $gets; // } }