zoukankan      html  css  js  c++  java
  • php数组转换成json格式。

       {
               "touser":"OPENID",
               "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
               "url":"http://weixin.qq.com/download",            
               "data":{
                       "first": {
                           "value":"恭喜你购买成功!",
                           "color":"#173177"
                       },
                       "keynote1":{
                           "value":"巧克力",
                           "color":"#173177"
                       },
                       "keynote2": {
                           "value":"39.8元",
                           "color":"#173177"
                       },
                       "keynote3": {
                           "value":"2014年9月22日",
                           "color":"#173177"
                       },
                       "remark":{
                           "value":"欢迎再次购买!",
                           "color":"#173177"
                       }
               }
           }
    
    
    
    
    
    public function settemplateMsg(){
        
            $templateID = "oCn07pNLLCgUP9KN4T34sCs69nIqrBgtuCtAdVWaHOg";
            $posttemepleUrl ="https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$this->access_token;
    
    
            $postData = array();
            $postData['touser']= "o2Q4wtwk4NlLqy7QwTWG5vc8RVus";
            $postData['template_id']= $templateID;
            $postData['url']= "http://m.ancun.org/wxmsg/index.php/home/attention";
    
            
            $templArr= array();
            $templArr['first'] = array('value'=>'有美女给你发信息啦','color'=>'#173177');
            $templArr['keyword1'] = array('value'=>'明天你有时间吗。我要你出来一下。','color'=>'#173177');
            $templArr['keyword2'] = array('value'=>'存宝系统 ','color'=>'#173177');
            $templArr['keyword3'] = array('value'=>'王您码','color'=>'#173177');
            $templArr['keyword4'] = array('value'=>'2014年9月22日','color'=>'#173177');
            $templArr['remark'] = array('value'=>'欢迎再次使用。','color'=>'#173177');
            
            $postData['data']= $templArr;
            
            $postData = json_encode($postData);
    
            $result =  $this->http_request($posttemepleUrl,$postData);
            return json_decode($result,true);
    
    
        }
  • 相关阅读:
    struts.xml文件中package元素的各大属性讲解
    strus2 struts.xml详解
    既使用maven编译,又使用lib下的Jar包
    Maven项目同时使用lib下的Jar包
    PreparedStatement ResultSet
    SearchBySql
    java 生成GUID
    获取当前时间的字符串
    C#字符串比较
    浮点数比较大小
  • 原文地址:https://www.cnblogs.com/longhs/p/4923380.html
Copyright © 2011-2022 走看看