热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

微信现金红包接口实现红包发放的示例代码分享

后端程序调用接口发放红包--》微信用户在微信中收到红包--》打开红包--》红包金额会添加到钱包零钱里--》完成红包发放。】
微信现金红包接口实现红包发放:

一:流程:【

流程:微信用户访问红包活动页面--》后端判断是否是微信访问的

【否:提示用微信打开连接,是:提示用户是否授权允许,获取其的用户信息【openID等信息】】--》

进入红包活动页面---》用户点击领取红包【判断是否领取过红包】是:【提示已领取过红包】否

--》后端程序调用接口发放红包

--》微信用户在微信中收到红包

--》打开红包

--》红包金额会添加到钱包零钱里

--》完成红包发放。

二:要实现微信现金红包接口实现红包发放,首先要符合以下条件:

1.用于发放红包的微信公众号要是服务类型

2.登录微信公众平台官网后,在公众平台后台管理页面 - 开发者中心页,

点击“修改配置”按钮,填写服务器地址(URL)、Token和EncodingAESKey,

其中URL是开发者用来接收微信消息和事件的接口URL。Token可由开发者可以任意填写,

用作生成签名(该Token会和接口URL中包含的Token进行比对,从而验证安全性)。

EncodingAESKey由开发者手动填写或随机生成,将用作消息体加解密密钥。

3.获取access_token:公众号可以使用AppID和AppSecret调用本接口来获取access_token。

【AppID和AppSecret可在微信公众平台官网-开发者中心页中获得(需要已经成为开发者,且帐号没有异常状态)。】

4.微信公众号要开通 “网页授权接口” 用户获取用户基本信息【特别是openID ,发红包时用到】

5.微信公众号的 “微信支付“ 中的 ”商户号” 要开通微信支付【发红包的金额是该支付账户扣款】,开通“现金红包”接口【调用该接口发放红包】。

6. 登陆 ”商户号”【微信公众号分配的商户号。第5 中有说明】 在 “API安全” 中 下载PHP版的 证书 【.pem格式】

以上如描述不清楚,请查看 微信开发者文档 里面有详细的秒杀。

部分代码如下【其余的请查看附件】:

isWeixin();//是否是微信打开
                if($this->access)
                    {
                        $this->display();
                         
                    }
                    else
                        {
                            $class=new Oauth();
                            $class->index('http://www.myweb.com/index.php/Index/oauth');
                        }
            }
         
        //获取用户信息 openID
        public function oauth()
            {
                $code=isset($_GET['code'])?strip_tags(trim($_GET['code'])):'';
                $state=isset($_GET['state'])?strip_tags(trim($_GET['state'])):'';
                 
                $class=new Oauth();
                $userInfo=$class->getCode($code,$state);//获取用户信息
                if(!empty($userInfo['data']))
                    {
                        //$model=M('wxuser');
                        //$result=$model->where('openid = "'.$userInfo['data']->openid.'"')->field('openid')->select();
                        if(empty($result))
                            {
                                $userInfo['data']=$this->object2array($userInfo['data']);
                                $model->data($userInfo['data'])->add();
                                 
                            }
                    }
                $userInfo['data']=$this->object2array($userInfo['data']);
                 
                //创建红包
                $class=new CreateRedPack();
                $red=$class->redval();
                 
                //发红包
                $class=new SendRedPack();
                $cOnfigs=array(
                        'send_name'=>'红包发送者名称',//红包发送者名称
                        're_openid'=>$userInfo['data']['openid'],//接受红包的用户,用户在wxappid下的openid
                        'total_amount'=>$red,//付款金额,单位分
                        'total_num'=>'1',//红包发放总人数
                        'wishing'=>'红包祝福语',//红包祝福语
                        'client_ip'=>$_SERVER['SERVER_ADDR'],//调用接口的机器Ip地址
                        'act_name'=>'活动名称',//活动名称
                        'remark'=>'备注信息',//  备注信息
                    );
                $class->setFields($configs);
                $result=$class->requestXml();
                 
                //微信返回信息处理
                if(strtoupper($result['return_code'])=='SUCCESS')
                    {
                        if(strtoupper($result['result_code'])=='SUCCESS')
                            {
                                //红包发送成功!
                                                         
                                $datas['flag']=1;
                                echo $result['err_code_des'];
                            }
                            else
                                {
                                    //红包发送失败
                                    $datas['flag']=0;
                                    $datas['msg']=$result['err_code_des'];
                                    echo $result['err_code_des'];
                                }
                    }
                    else
                        {
                            //红包发送失败
                            $datas['flag']=0;
                            $datas['msg']=$result['err_code_des'];
                            echo $result['err_code_des'];
                        }
            }
         
        public function isWeixin()
            {
                if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) 
                    { 
                        $this->access=true; 
                    } 
                return false; 
            }
         
        //类转换成数组
        public function object2array($object) 
            {
              if (is_object($object)) 
                  {
                    foreach ($object as $key => $value) 
                        {
                          $array[$key] = $value;
                        }
                  }
                  else 
                      {
                        $array = $object;
                      }
              return $array;
            }
             
    }
    ?>
1.0,'max'=>1.1),
                                array('min'=>1.1,'max'=>1.2),
                                array('min'=>1.2,'max'=>1.95)
                            );
                             
        public function __construct()
            {
                $this->rid=mt_rand(1,10000);//当前红包随机数
                $this->rand_arr=range(1,3500);//35%是1.0到1.1
                $this->rand_arr1=range(3501,7000);//35%是1.1到1.2
                $this->rand_arr2=range(7001,10000);//30%是1.2到1.95
                $this->simplered=666;
            }
             
        public function redval()
            {
                $maxrp=$this->maxred();//随机最大红包金额
                if($maxrp!=$this->simplered)
                    {
                        if(in_array($this->rid,$this->rand_arr))
                            {
                                $red_val=$this->red_config[0];
                                $min=$red_val['min']*100;
                                $max=$red_val['max']*100;
                                $this->red=mt_rand($min,$max);
                                $this->red=$this->red/100;
                            }
                            elseif(in_array($this->rid,$this->rand_arr1))
                                {
                                    $red_val=$this->red_config[1];
                                    $min=$red_val['min']*100;
                                    $max=$red_val['max']*100;
                                    $red=mt_rand($min,$max);
                                    $this->red=$this->red/100;
                                }
                                elseif(in_array($this->rid,$this->rand_arr2))
                                    {
                                        $red_val=$this->red_config[2];
                                        $min=$red_val['min']*100;
                                        $max=$red_val['max']*100;
                                        $this->red=mt_rand($min,$max);
                                        $this->red=$this->red/100;
                                    }
                    }
                    else
                        {
                            $this->red=$maxrp;
                        }
                return $this->red?$this->red:1;
            }
                 
        protected function maxred()
            {
                $rid=mt_rand(1,100000);
                $rid1=mt_rand(1,100000);
                $red=0;
                $dff=$rid-$rid1;
                 
                if($dff > 0)
                    {
                        if(($rid1%$rid1)==$this->simplered)
                            {
                                $red=$this->simplered;
                            }
                    }
                    else
                        {
                            if(($rid1%$rid)==$this->simplered)
                                {
                                    $red=$this->simplered;
                                }
                        }
                         
                return $red;
            }
    }
 
?>
0,'msg'=>'','data'=>'');
         
         
        public function __construct()
            {
                $this->appid='appid';//
                $this->appsecret='secret';//;
                $this->state=mt_rand(100,999);
            }
             
        //引导用户访问链接处理函数 
        public function index($redirect_uri)
            {
                $this->redirect_uri=urlencode($redirect_uri);//微信自动跳转到$redirect_uri
                header('location:https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$this->appid.'&redirect_uri='.$this->redirect_uri.'/oauth.php&response_type=code&scope=snsapi_userinfo&state='.$this->state.'&connect_redirect=1#wechat_redirect');
            }
             
        public function getCode($code='',$state='',$token='',$webToken='')
            {
                $data=array(
                    'errorno'=>'',
                    'errormsg'=>'',
                    'data'=>''
                );
                 
                if(empty($code))
                    {
                        $this->data['flag']=0;
                        $this->data['msg']='授权失败!';
                    }
                    else
                        {   /* 
                                 
                                1获取webtoken
                                2获取reflash_token
                                3获取用户信息 
                            */
  $token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->appid.'&secret='.$this->appsecret.'&code='.$code.'&grant_type=authorization_code';
                         $token = json_decode(file_get_contents($token_url));
                             
                            if (isset($token->errcode)) 
                                {
                                    $data['errorno']=$token->errcode;
                                    $data['errormsg']=$token->errmsg;
                                }
                                else
                                    {
  $access_token_url = 'https://api.weixin.qq.com/sns/oauth2/refresh_token?appid='.$this->appid.'&grant_type=refresh_token&refresh_token='.$token->refresh_token;
                                        //转成对象
                                        $accessToken = json_decode(file_get_contents($access_token_url));
                                         
                                        if (isset($accessToken->errcode)) 
                                            {
                                                $data['errorno']=$token->errcode;
                                                $data['errormsg']=$token->errmsg;
                                            }
                                            else
                                                {
     $user_info_url = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$accessToken->access_token.'&openid='.$accessToken->openid.'&lang=zh_CN';
                                                    //转成对象
                                                    $userInfo = json_decode(file_get_contents($user_info_url));
                                                     
                                                    if (isset($userInfo->errcode)) 
                                                        {
                                                            $data['errorno']=$token->errcode;
                                                            $data['errormsg']=$token->errmsg;
                                                        }
                                                        else
                                                            {
                                                                $data['data']=$userInfo;
                                                            }
                                                }
                                    }
                        }
                return $data;
            }
             
    }
 
?>
'',//随机字符串,不长于32位
            'sign'=>'',//签名
            'mch_billno'=>'',//商户订单号
            'mch_id'=>'1111sdfsafsaddf',//微信支付分配的商户号
            'wxappid'=>'sddafdsadfdsafdsdd',//微信分配的公众账号ID
            'send_name'=>'',//红包发送者名称
            're_openid'=>'',//接受红包的用户,用户在wxappid下的openid
            'total_amount'=>'',//付款金额,单位分
            'total_num'=>'',//红包发放总人数
            'wishing'=>'',//红包祝福语
            'client_ip'=>'',//调用接口的机器Ip地址
            'act_name'=>'',//活动名称
            'remark'=>'',//  备注信息
        );
         
        protected $key='';
        protected $url='https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack';
        protected $requestXml='';
         
        //设置必要参数
        public function setFields($cOnf=array())
            {
                foreach($conf as $k=>$v)
                    {
                        if(isset($this->config[$k]) && !empty($v))
                            {
                                $this->config[$k]=$v;
                            }
                    }
                $this->config['mch_billno']=$this->billno();
                $this->config['nonce_str']=$this->createNonceStr();
                $this->createSign($conf);
                $this->createXml();
                //echo $this->requestXml;
            }
         
        protected function billno()
            {
                return $this->config['mch_id'].time().md5(mt_rand(1000,9999));
            }
         
        /* //检查必要参数是否为空!
        public function checkConfig()
            {
                $flag=true;
                foreach($this->config as $k=>$v)
                    {
                        if(empty($v))
                            {
                                $flag=false;
                                break;
                            }
                    }
            } */
         
        //随机字符串,不长于32位
        public function createNonceStr( $len=32 )
            {
                $strs = "abcdefghijklmnopqrstuvwxyz0123456789";
                $str ="";
                $len=$len<=32?$len:32;
                for ( $i = 0; $i <$len; $i++ )
                    {
                      $str.= substr($strs, mt_rand(0, strlen($strs)-1), 1);
                    }
                return $str;
            }
             
        //格式化参数
        public function formatParam($cOnfig=array(),$flag=1)
            {
                $format=&#39;&#39;;
                if(!empty($config))
                    {
                        ksort($config);
                        foreach($config as $k=>$v)
                            {
                                if($flag)
                                    {
                                        $v=urlencode($v);
                                    }
                                     
                                    if($flag==0 && strtolower($k)==&#39;sign&#39;)
                                        {
                                            continue;
                                        }
                                $format.=$k.&#39;=&#39;.$v.&#39;&&#39;;
                            }
                        $format=trim($format,&#39;&&#39;);
                    }
                return $format;
            }
             
        //创建SIGNATURE  
        protected function createSign($config)
            {
                $format=$this->formatParam($config,0);
                $format.=&#39;&key=&#39;.$this->key;
                $signature=strtoupper(md5($format));
                $this->config[&#39;sign&#39;]=$signature;
                return true;//$signature;
            }
             
        //创建xml格式数据
        protected function createXml()
            {
                $xml=&#39;&#39;;
                foreach($this->config as $k=>$v)
                    {
                        if(!empty($v))
                            {
                                $xml.=&#39;<&#39;.$k.&#39;>&#39;;
                            }
                    }
                $xml.=&#39;&#39;;
                $this->requestXml=$xml;
            }
         
        //XML格式数据转换为数组
        public function createArray($xml=&#39;&#39;)
            {
                $arr = json_decode(json_encode(simplexml_load_string($xml, &#39;SimpleXMLElement&#39;, LIBXML_NOCDATA)), true);
                return $arr;
            }
         
        //发送红包
        public function requestXml($timeout=30,$header=array())
            {
                $ch = curl_init();
                //超时时间
                curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);
                curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch,CURLOPT_URL,$this->url);
                curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
                curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
                //默认格式为PEM,可以注释
                curl_setopt($ch,CURLOPT_SSLCERTTYPE,&#39;PEM&#39;);
                curl_setopt($ch,CURLOPT_SSLCERT,dirname(__FILE__).&#39;/apiclient_cert.pem&#39;);//pem证书地址
                //默认格式为PEM,可以注释
                curl_setopt($ch,CURLOPT_SSLKEYTYPE,&#39;PEM&#39;);
                curl_setopt($ch,CURLOPT_SSLKEY,dirname(__FILE__).&#39;/apiclient_key.pem&#39;);//key证书地址
                curl_setopt($ch,CURLOPT_CAINFO,&#39;PEM&#39;);
                curl_setopt($ch,CURLOPT_CAINFO,dirname(__FILE__).&#39;/rootca.pem&#39;);//CA证书地址
                //两个文件合成一个.pem文件
                //curl_setopt($ch,CURLOPT_SSLCERT,getcwd().&#39;/all.pem&#39;);
                if( count($header) >= 1 )
                    {
                        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
                    }
                curl_setopt($ch,CURLOPT_POST, 1);
                curl_setopt($ch,CURLOPT_POSTFIELDS,$this->requestXml);
                $data = curl_exec($ch);
                var_dump($data);
                if($data)
                    {
                        curl_close($ch);
                        var_dump($data);
                        return $data;
                    }
                    else 
                        {
                            $error = curl_errno($ch);
                            echo &#39;ERROR:&#39;.$error;
                            curl_close($ch);
                            return false;
                        }
            }
         
        //返回非空值,非NULL
        public function notEmpty($val=&#39;&#39;)
            {
                $return=&#39;&#39;;
                if(null !=$val && strlen($val) != 0)
                    {
                        $return=$val;
                    }
                return $return?$return:false;
            }
         
    }
 
 
?>
&#39;1&#39;,&#39;expires&#39;=>&#39;7200&#39;);
                 
            }
             
        //设置获取ACCESSTOKEN 的URL
        public function setUrl()
            {
                return $this->url=$this->url.&#39;?grant_type=&#39;.$this->grant_type.&#39;&appid=&#39;.$this->AppID.&#39;&secret=&#39;.$this->AppSecret;
            }
         
        //获取APPID,SECRET
        public function getAppid()
            {
                $sql=&#39;select appid,secret from ly_appid where flag=1&#39;;
                $model=M();
                $result=$model->query($sql);
                if(!empty($result))
                    {
                        $this->AppID=$result[0][&#39;appid&#39;];
                        $this->AppSecret=$result[0][&#39;secret&#39;];
                        return $result[0];
                    }
            }
             
        public function object2array($object) 
            {
              if (is_object($object)) 
                  {
                    foreach ($object as $key => $value) 
                        {
                          $array[$key] = $value;
                        }
                  }
                  else 
                      {
                        $array = $object;
                      }
              return $array;
            }
             
        //检验URL有效
        public function checkUrl()
            {
                $signature=isset($_GET[&#39;signature&#39;])?strip_tags(trim($_GET[&#39;signature&#39;])):&#39;&#39;;
                $timestamp=isset($_GET[&#39;timestamp&#39;])?strip_tags(trim($_GET[&#39;timestamp&#39;])):&#39;&#39;;
                $nOnce=isset($_GET[&#39;nonce&#39;])?strip_tags(trim($_GET[&#39;nonce&#39;])):&#39;&#39;;
                $echostr=isset($_GET[&#39;echostr&#39;])?$_GET[&#39;echostr&#39;]:&#39;&#39;;
                if(!empty($signature) && !empty($timestamp) && !empty($nonce))
                    {
                        if($this->checkSign($signature,$timestamp,$nonce))
                            {
                                echo $echostr;
                                return true;
                            }
                            else
                                {
                                    return false;
                                }
                    }
            }  
             
        //验证SIGNATURE是否有效
        private function checkSign($sign,$timestamp,$nonce)
            {
                $token=$this->getAccessToken();
                //$token=$this->object2array($token);
                $sign_arr=array($token,$timstamp,$nonce);
                sort($sign_arr,SORT_STRING);
                $signStr=implode($sign_arr);
                $signStr=sha1($signStr);
                if(strtoupper($signStr)==strtoupper($sign))
                    {
                        return true;
                    }
                return false;
            }
             
        //通过微信接口获取微信Access_Token   
        public function getAccessToken()
            {
                $token=&#39;&#39;;
                $this->setUrl();
                $check=$this->checkToken();
                 
                if(session(&#39;?&#39;.md5(&#39;getaccesstoken&#39;)) && $check)
                    {
                        $tokens=session(md5(&#39;getaccesstoken&#39;));
                        $token=$tokens->access_token;
                    }
                    else
                        {
                            $result=file_get_contents($this->url);
                            $result=json_decode($result);
                            $token=$result->access_token;
                            $result->expires_in=$result->expires_in+time();
                            session(md5(&#39;getaccesstoken&#39;),$result);
                        }
                         
                return $token;
            }
         
        //检查微信ACCESS_TOKEN是否有效
        public function checkToken()
            {
                if(session(&#39;?&#39;.md5(&#39;getaccesstoken&#39;)) && session(md5(&#39;getaccesstoken&#39;)))
                    {
                        $time=time();
                        $token=session(md5(&#39;getaccesstoken&#39;));
                         
                        if($token->expires_in-$time > 30)
                            {
                                return true;
                            }
                            else
                                {
                                    session(md5(&#39;getaccesstoken&#39;),null);
                                }
                    }
                return false;
            }
             
        //保存微信ACCESSTOKEN到数据库  
        public function saveAccessToken()
            {
                $token=$this->getAccessToken();
                $sql=&#39;select `id`,`rate`,token,ex_time,createtime from ly_token where token="&#39;.$token.&#39;" where appid="&#39;.$this->AppID.&#39;" AND secret="&#39;.$this->AppSecret.&#39;"&#39;;
                $model=M();
                $result=$model->query($sql);
                if(!empty($result))
                    {
                        $time=time();
                        $expires=$time-$result[0][&#39;createtime&#39;];
                        if($result[0][&#39;ex_time&#39;]-$expires > 0)
                            {
                                return $result[0][&#39;token&#39;];                       
                            }
                            else
                                {
                                    $token=$this->getAccessToken();
                                    if(!empty($token))
                                        {
                                            $token=json_decode($token);
                                            if(!isset($token[&#39;errcode&#39;]) or !$token[&#39;errcode&#39;])
                                                {
                                                    if(isset($token[&#39;access_token&#39;]) && $token[&#39;access_token&#39;])
                                                        {
                                                            $data[&#39;access_token&#39;]=$token[&#39;access_token&#39;];
                                                            $data[&#39;createtime&#39;]=$time;
                                                            $data[&#39;ex_time&#39;]=$token[&#39;expires_in&#39;];
                                                            $data[&#39;rate&#39;]=$result[0][&#39;rate&#39;]+1;
                                                            //$sql=&#39;update ly_token set token="&#39;.$token[&#39;access_token&#39;].&#39;" ,createtime=&#39;.$time.&#39;,ex_time=&#39;.$token[&#39;expires_in&#39;].&#39; where `id`=&#39;.$result[0][&#39;id&#39;];
                                                            $model=M(&#39;token&#39;);
                                                            $update=$model->where(&#39;`id`=&#39;.$result[0][&#39;id&#39;])->save($data);
                                                            if($update)
                                                            {
                                                                return $token[&#39;access_token&#39;];
                                                            }
                                                        }
                                                }
                                                else
                                                    {//微信返回的错误信息
                                                                $data[&#39;errcode&#39;]=$token[&#39;errcode&#39;];
                                                                $data[&#39;errmsg&#39;]=$token[&#39;errmsg&#39;];
                                                                $data[&#39;appid&#39;]=$this->AppID;
                                                                $data[&#39;secret&#39;]=$this->AppSecret;
                                                                $data[&#39;createtime&#39;]=time();
                                                                $data[&#39;rate&#39;]=$result[0][&#39;rate&#39;]+1;
                                                                $ein=$model->where(&#39;`id`=&#39;.$result[0][&#39;id&#39;])->save($data);
                                                                if($ein)
                                                                    {
                                                                        return false;
                                                                    }
                                                    }
                                        }
                                }
                    }
                    else
                        {//新插入数据库保存
                            $token=$this->getAccessToken();
                            $model=M(&#39;token&#39;);
                            if(!empty($token))
                                        {
                                            $data=array();
                                            $token=json_decode($token);
                                            if(!isset($token[&#39;errcode&#39;]) or !$token[&#39;errcode&#39;])
                                                {
                                                    if(isset($token[&#39;access_token&#39;]) && $token[&#39;access_token&#39;])
                                                        {
                                                            $data[&#39;access_token&#39;]=$token[&#39;access_token&#39;];
                                                            $data[&#39;createtime&#39;]=$time;
                                                            $data[&#39;ex_time&#39;]=$token[&#39;expires_in&#39;];
                                                            //$sql=&#39;insert into ly_token() vlaues()&#39;;
                                                            $data[&#39;rate&#39;]=1;
                                                            $in=$model->data($data)->add();
                                                            if($ein)
                                                            {
                                                                $token[&#39;access_token&#39;];
                                                            }
                                                        }
                                                }
                                                else
                                                    {//微信返回的错误信息
                                                        $data[&#39;errcode&#39;]=$token[&#39;errcode&#39;];
                                                        $data[&#39;errmsg&#39;]=$token[&#39;errmsg&#39;];
                                                        $data[&#39;appid&#39;]=$this->AppID;
                                                        $data[&#39;secret&#39;]=$this->AppSecret;
                                                        $data[&#39;createtime&#39;]=time();
                                                        $data[&#39;rate&#39;]=1;
                                                        $ein=$model->data($data)->add();
                                                        if($ein)
                                                            {
                                                                return false;
                                                            }
                                                    }
                                        }
                        }
                return false;
            }  
             
             
             
             
             
    }
 
?>

以上就是 微信现金红包接口实现红包发放的示例代码分享的详细内容,更多请关注php中文网其它相关文章!


推荐阅读
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • 生成对抗式网络GAN及其衍生CGAN、DCGAN、WGAN、LSGAN、BEGAN介绍
    一、GAN原理介绍学习GAN的第一篇论文当然由是IanGoodfellow于2014年发表的GenerativeAdversarialNetworks(论文下载链接arxiv:[h ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • t-io 2.0.0发布-法网天眼第一版的回顾和更新说明
    本文回顾了t-io 1.x版本的工程结构和性能数据,并介绍了t-io在码云上的成绩和用户反馈。同时,还提到了@openSeLi同学发布的t-io 30W长连接并发压力测试报告。最后,详细介绍了t-io 2.0.0版本的更新内容,包括更简洁的使用方式和内置的httpsession功能。 ... [详细]
  • Java String与StringBuffer的区别及其应用场景
    本文主要介绍了Java中String和StringBuffer的区别,String是不可变的,而StringBuffer是可变的。StringBuffer在进行字符串处理时不生成新的对象,内存使用上要优于String类。因此,在需要频繁对字符串进行修改的情况下,使用StringBuffer更加适合。同时,文章还介绍了String和StringBuffer的应用场景。 ... [详细]
  • 本文介绍了Java的集合及其实现类,包括数据结构、抽象类和具体实现类的关系,详细介绍了List接口及其实现类ArrayList的基本操作和特点。文章通过提供相关参考文档和链接,帮助读者更好地理解和使用Java的集合类。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • 本文介绍了游戏开发中的人工智能技术,包括定性行为和非定性行为的分类。定性行为是指特定且可预测的行为,而非定性行为则具有一定程度的不确定性。其中,追逐算法是定性行为的具体实例。 ... [详细]
  • JavaScript设计模式之策略模式(Strategy Pattern)的优势及应用
    本文介绍了JavaScript设计模式之策略模式(Strategy Pattern)的定义和优势,策略模式可以避免代码中的多重判断条件,体现了开放-封闭原则。同时,策略模式的应用可以使系统的算法重复利用,避免复制粘贴。然而,策略模式也会增加策略类的数量,违反最少知识原则,需要了解各种策略类才能更好地应用于业务中。本文还以员工年终奖的计算为例,说明了策略模式的应用场景和实现方式。 ... [详细]
  • 本文介绍了PhysioNet网站提供的生理信号处理工具箱WFDB Toolbox for Matlab的安装和使用方法。通过下载并添加到Matlab路径中或直接在Matlab中输入相关内容,即可完成安装。该工具箱提供了一系列函数,可以方便地处理生理信号数据。详细的安装和使用方法可以参考本文内容。 ... [详细]
author-avatar
今天是星期天嘛_512
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有