微信公众号支付,接收事件订阅后苏醒响应音讯

www.5929.com 1

效率是在关注意创3D打印测试本条订阅号之后,输入月日,比如0204(代表四月4日),会接收不少天历史上的这一天发生的大事件。

首先接触的时候写的一部分,有点乱…也没去整理…
ps–方今都不想做事了,种种烦,午饭也没吃,就是想表明一下自身过的不得了。–请忽略个人心情往下看。

//接受事件推送并回复

www.5929.com 2

代码布置环境是用了博客园sae,thinkphp框架基础上落实效益。

 代码如下

public function reponseMsg(){

www.5929.com 3www.5929.com 4

控制器中:

<?php
/**
 * 微信公物平台消息回复类
 *

     //1.获取微信推送过来的post数据(xml格式)

www.5929.com 5

<?PHP
namespace Home\Controller;
use Think\Controller;

 *
 */
class BBCweixin{
 
 private $APPID=”******”;
 private $APPSECRET=”******”;
 /*
  *文本新闻回复
  *@param array object
  *@param string content
  *@return string
  */
 public function resText($object,$content,$flag=0){
  $xmlText=”<xml>
                 
<ToUserName><![CDATA[%s]]></ToUserName>
                 
<FromUserName><![CDATA[%s]]></FromUserName>
                  <CreateTime>%s</CreateTime>
                 
<MsgType><![CDATA[text]]></MsgType>
                 
<Content><![CDATA[%s]]></Content>
                  <FuncFlag>%d</FuncFlag>
                  </xml>”;
    
$resultStr=sprintf($xmlText,$object->FromUserName,$object->ToUserName,time(),$content,$flag);
  echo $resultStr;exit();
 }
 /*
  *图形音讯回复
  *@param array object
  *@param string url
  *@return string
  */
 public function resImage($object,$media_id){
  $xmlImage=”<xml>”;
  $xmlImage.=”<ToUserName><![CDATA[%s]]></ToUserName>”;
  $xmlImage.=”<FromUserName><![CDATA[%s]]></FromUserName>”;
  $xmlImage.=”<CreateTime>%s</CreateTime>”;
  $xmlImage.=”<MsgType><![CDATA[image]]></MsgType>”;
  $xmlImage.=”<Image><MediaId><![CDATA[%s]]></MediaId></Image>”;
  $xmlImage.=”</xml>”;
  $resultStr=sprintf($xmlImage,$object->FromUserName,$object->ToUserName,time(),$media_id);
  echo $resultStr;exit();
 }
 /*
  *图文信息回复
  *@param array object
  *@param array newsData 二维数组
必须带有[Title][Description][PicUrl][Url]字段
  *@return string
  */
 public function resNews($object,$newsData=array()){
     $CreateTime=time();
     $FuncFlag=0;
     $newTplHeader=”<xml>
       
<ToUserName><![CDATA[{$object->FromUserName}]]></ToUserName>
       
<FromUserName><![CDATA[{$object->ToUserName}]]></FromUserName>
        <CreateTime>{$CreateTime}</CreateTime>
        <MsgType><![CDATA[news]]></MsgType>
        <Content><![CDATA[%s]]></Content>
        <ArticleCount>%s</ArticleCount><Articles>”;
     $newTplItem=”<item>
      <Title><![CDATA[%s]]></Title>
      <Description><![CDATA[%s]]></Description>
      <PicUrl><![CDATA[%s]]></PicUrl>
      <Url><![CDATA[%s]]></Url>
      </item>”;
     $newTplFoot=”</Articles>
      <FuncFlag>%s</FuncFlag>
      </xml>”;
     $Content=”;
     $itemsCount=count($newsData);
    
$itemsCount=$itemsCount<10?$itemsCount:10;//微信公众平台图文回复的音信四遍最多10条
     if($itemsCount){
      foreach($newsData as
$key=>$item){
       if($key<=9){
  
   $Content.=sprintf($newTplItem,$item[‘Title’],$item[‘Description’],$item[‘PicUrl’],$item[‘Url’]);
    }
      }
  }
     $header=sprintf($newTplHeader,0,$itemsCount);
     $footer=sprintf($newTplFoot,$FuncFlag);
     echo $header.$Content.$footer;exit();
 }
 
 /*
  *音乐新闻回复
  *@param array object
  *@param array musicContent 二维数组
蕴含[Title][Description][MusicUrl][HQMusicUrl]字段
  *@return string
  */
 public function resMusic($object,$musicContent=array()){
   $xmlMusic=”<xml>
                   
<ToUserName><![CDATA[%s]]></ToUserName>
微信公众号支付,接收事件订阅后苏醒响应音讯。                   
<FromUserName><![CDATA[%s]]></FromUserName>
                    <CreateTime>%s</CreateTime>
                   
<MsgType><![CDATA[music]]></MsgType>
                    <Music>
     <Title><![CDATA[%s]]></Title>
                   
<Description><![CDATA[%s]]></Description>
                   
<MusicUrl><![CDATA[%s]]></MusicUrl>
                   
<HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
                    </Music>
                    </xml>”;
  if(empty($musicContent[0][‘HQMusicUrl’])){
   $musicContent[0][‘HQMusicUrl’]=$musicContent[0][‘MusicUrl’];
  }
  $resultStr=sprintf($xmlMusic,$object->FromUserName,$object->ToUserName,time(),$musicContent[0][‘Title’],$musicContent[0][‘Description’],$musicContent[0][‘MusicUrl’],$musicContent[0][‘HQMusicUrl’]);
  echo $resultStr;exit();
 }
 /*
  *上传多媒体文件接口
  *@param
  *@param array mediaArr filename、filelength、content-type
  *@return object
  */
 public function uploadMedia($accessToken,$type=’image’,$mediaArr){
  $url=”;
  $doPost=self::curlPost($mediaArr,$url);
  return $doPost;
微信公众号支付,接收事件订阅后苏醒响应音讯。 }
 /*
  *GPS,谷歌(谷歌(Google))坐标转换成百度坐标
  *@param lnt
  *@param lat
  *@return array
  */
 public function mapApi($lng,$lat,$type){
  $map=array();
  if($type==’gps’){
   $url=”;
   $res=json_decode(file_get_contents($url));
   $map[‘lng’]=$res->baidu->lng;
   $map[‘lat’]=$res->baidu->lat;
  }
  if($type==’google’){
   $url=”;
   $res=json_decode(file_get_contents($url));
   $map[‘lng’]=base64_decode($res[0]->x);
   $map[‘lat’]=base64_decode($res[0]->y);
  }
  return $map;
 }
 
 /**************************************************************
  *
  *  使用特定function对数组中存有因素做拍卖
  *  @param  string  &$array     要拍卖的字符串
  *  @param  string  $function   要举行的函数
  *  @return boolean $apply_to_keys_also     是不是也利用到key上
  *  @access public
  *
 
*************************************************************/
 public function arrayRecursive(&$array, $function,
$apply_to_keys_also = false)
 {
  static $recursive_counter = 0;
  if (++$recursive_counter > 1000) {
   die(‘possible deep recursion attack’);
  }
  foreach ($array as $key => $value) {
   if (is_array($value)) {
    self::arrayRecursive($array[$key], $function,
$apply_to_keys_also);
   } else {
    $array[$key] = $function($value);
   }
 
   if ($apply_to_keys_also && is_string($key)) {
    $new_key = $function($key);
    if ($new_key != $key) {
     $array[$new_key] = $array[$key];
     unset($array[$key]);
    }
   }
  }
  $recursive_counter–;
 }
 
 /**************************************************************
  *
  *  将数组转换为JSON字符串(包容汉语)
  *  @param  array   $array      要转换的数组
  *  @return string      转换得到的json字符串
  *  @access public
  *
 
*************************************************************/
 public function JSON($array) {
  self::arrayRecursive($array, ‘urlencode’, true);
  $json = json_encode($array);
  return urldecode($json);
 }
 /*
  *始建菜单
  *
  */
 public function creatMenu($shop_id,$data){
  $jsonArray=self::JSON($data);
  $AccessToken=self::accessToken($weiXin[0][‘key’],$weiXin[0][‘secret’]);
  $MENU_URL=”;
  return self::curlPost($jsonArray,$MENU_URL);
 }
 /*
  *客服消息回复
  *@param array jsonArray Array
{“touser”:”OPENID”,”msgtype”:”text”,”text”:{“content”:”Hello World”}}
  *@return string
  */
 
  public function customService($jsonArray,$hash){
  if(empty($jsonArray)){
   return false; 
  }
  $db=M();
  $sql=”select * from
bbc_wechats where hash='”.$hash.”‘”;
  $weChast=$db->query($sql);
  $AccessToken=self::accessToken($weChast[0][‘key’],$weChast[0][‘secret’]);
  $TokenUrl=”;
     $CustomRes=self::curlPost($jsonArray,$TokenUrl);
  return $CustomRes;
  }
  /*
 
   *获取access_token
   *@return objectStr
   */
  public function accessToken($appid,$secret){
   $access_token=BBCcache::getCache(‘accesstoken’.$appid);
   if($access_token){
    $AccessTokenRet=$access_token;
   }else{
   
$TookenUrl=””;
    $AccessTokenRes=@file_get_contents($TookenUrl);
    $AccessToken=json_decode($AccessTokenRes);
    $AccessTokenRet=$AccessToken->access_token;
   
BBCcache::setCache(‘accesstoken’.$appid,$AccessToken->access_token,3600);
   }
   return $AccessTokenRet;
  }
  /*
   *向远程接口POST数据
   *@data Array
{“touser”:”OPENID”,”msgtype”:”text”,”text”:{“content”:”Hello World”}}
   *@return objectArray
   */
  public function curlPost($data,$url){
    $ch = curl_init();
 
   curl_setopt($ch,
CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
   curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (compatible; MSIE
5.01; Windows NT 5.0)’);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
   $info = curl_exec($ch);
 
   if (curl_errno($ch)) {
    echo ‘Errno’.curl_error($ch);
   }
 
   curl_close($ch);
   return json_decode($info);
  }
 //按照经纬度统计距离和大势
 function getRadian($d){
  return $d * M_PI / 180;
 }
 
 function getDistance ($lat1, $lng1, $lat2, $lng2){
  $EARTH_RADIUS=6378.137;//地球半径
  $lat1 =getRadian($lat1);
  $lat2 = getRadian($lat2);
 
  $a = $lat1 – $lat2;
  $b = getRadian($lng1) – getRadian($lng2);
 
  $v = 2 * asin(sqrt(pow(sin($a/2),2) + cos($lat1) * cos($lat2) *
pow(sin($b/2),2)));
 
  $v = round($EARTH_RADIUS * $v * 10000) / 10000;
 
  return $v;
 }
 
}
 
?>

      $postArr = $GLOBALS[‘HTTP_RAW_POST_DATA’];

 

class IndexController extends Controller {
   
//token验证,微信服务器发送post请求过来
    public function index(){
      $timestamp = $_GET[“timestamp”];//a时间戳
      $nonce = $_GET[“nonce”];//随机数
      $token = “weixin”;//token
      $signature = $_GET[“signature”];//加密签名
      $echoStr = $_GET[“echostr”];;//随机字符串
      //1)将token、timestamp、nonce三个参数进行字典序排序
      $tmpArr = array($token, $timestamp, $nonce);
      sort($tmpArr, SORT_STRING);
     //2)将五个参数字符串拼接成一个字符串进行sha1加密
     $tmpStr = implode( $tmpArr );
     $tmpStr = sha1( $tmpStr );
    
//3)开发者获得加密后的字符串可与signature比较,标识该请求来源于微信
    if( ($tmpStr == $signature) && $echoStr ){
         echo  $echoStr;//第一遍对接
         exit;
       }else{
          
$this->responseMsg();//第二、三、、、、、、次对接,除了第几遍对接,将来的接入不会传递$echoStr
       }
    }
    public function responseMsg(){
       //获取到微信推送过来的多少
       $postArr = $GLOBALS[“HTTP_RAW_POST_DATA”];
       
       //处理音讯
        $postObj = simplexml_load_string($postArr);//转成了对象
       
//用户关注后,微信推送过来一个包罗用户音信的xml数据包,大家接到后并回复
        //判断信息类型
        if(strtolower($postObj->MsgType) == “event”){
            //判断事件类型,是订阅(subscribe),照旧退订(unsubscribe)
            if(strtolower($postObj->Event) == “subscribe”){
                //$content =
“旅行者,欢迎你–用户的openid:”.$postObj->FromUserName.”–开发者微信号:”.$postObj->ToUserName.”–音信类型:”.$postObj->MsgType.”–事件类型:”.$postObj->伊夫nt;
                $content =
“欢迎您,旅行者,快復苏,告诉你个潜在,你输入月日我就足以帮你查到历史上的大事件,比如0101”;
                $wxSdkModel = new \Home\Model\IndexModel();
                $wxSdkModel ->
reponseSubscribe($postObj,$content); 
            }
        }

      //2.处理音信类型,并设置回复类型和内容

 www.5929.com 6

 //调取历史上的明日接口,重临音信
        if(strtolower($postObj->MsgType) == “text”){
            $time = $postObj->Content;
            $yue = substr($time,0,2);
            $ri = substr($time,-2);
            //历史上的明天接口
            $path =
“”;
            //初始化
            $ch = curl_init();
            //设置参数
            curl_setopt($ch,CURLOPT_URL,$path);
           
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//将curl_exec()获取的音讯以文件流的款式再次回到,而不是直接出口
            //调接口
            $res = curl_exec($ch);
            //关闭
            curl_close($ch);
            if(curl_errno($ch)){
                echo curl_error($ch);
            }
            $arr =
json_decode($res,true);//不加true是对象,加true是数组
            $content = “一共查到”.$arr[‘total’].”条数据\n”;
            $arrnews = $arr[‘result’];
            foreach($arrnews as $k => $v){
                $content.=
$v[‘year’].”年的这一天”.$v[‘title’].”\n”;
            }
            $wxSdkModel = new \Home\Model\IndexModel();
            $wxSdkModel -> reponseText($postObj,$content);   
            }
    }

      $postObj = simplexml_load_string( $postArr );

 

 

      //判断该数据包是或不是是订阅的事件推送

//代码如下

 

      if( strtolower( $postObj->MsgType ) == ‘event’ ){

<?php
class IndexAction extends Action {

里头实例化的$wxSdkModel代表model类IndexModel.class.php

      //倘使是关爱subcribe事件

public function __construct(){

代码如下:

             if( strtolower( $postObj->MsgType ) == ‘subscribe’ ){

}

<?php
namespace Home\Model;
use Think\Model;

              //回复用户音信

public function index(){
//得到参数 signature nonce token timestamp echostr
$nonce = $_GET[‘nonce’];
$token = ‘imooc’;
$timestamp = $_GET[‘timestamp’];
$echostr = $_GET[‘echostr’];
$signature = $_GET[‘signature’];
//形成数组,然后按字典序排序
$array = array();
$array = array($nonce, $timestamp, $token);
sort($array);
//拼接成字符串,sha1加密 ,然后与signature进行校验
$str = sha1( implode( $array ) );
if( $str == $signature && $echostr ){
//第二回对接weixin api接口的时候
echo $echostr;
exit;
}else{
$this->reponseMsg();
}
}
// 接收事件推送并復苏
public function reponseMsg(){
//1.赢获得微信推送过来post数据(xml格式)
$postArr = $GLOBALS[‘HTTP_RAW_POST_DATA’];
//2.处理音讯类型,并安装回复类型和情节
/*<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[FromUser]]></FromUserName>
<CreateTime>123456789</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe]]></Event>
</xml>*/
$postObj = simplexml_load_string( $postArr );
//$postObj->ToUserName = ”;
//$postObj->FromUserName = ”;
//$postObj->CreateTime = ”;
//$postObj->MsgType = ”;
//$postObj->Event = ”;
// gh_e79a177814ed
//判断该数据包是或不是是订阅的轩然大波推送
if( strtolower( $postObj->MsgType) == ‘event’){
//如若是关爱 subscribe 事件
if( strtolower($postObj->Event == ‘subscribe’) ){
//回复用户消息(纯文本格式)
$toUser = $postObj->FromUserName;
$fromUser = $postObj->ToUserName;
$time = time();
$msgType = ‘text’;
$content =
‘欢迎关心我们的微信公众账号’.$postObj->FromUserName.’-‘.$postObj->ToUserName;
$template = “<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>”;
$info = sprintf($template, $toUser, $fromUser, $time, $msgType,
$content);
echo $info;
/*<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>12345678</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[你好]]></Content>
</xml>*/

class IndexModel{

                       $toUser  = $postObj->FromUserName;

}
}

//用户发送文书音信,接收到后回复文本消息
    public function reponseText($postObj,$content){
         $toUserName = $postObj->FromUserName;
         $fromUserName =
$postObj->ToUserName;//开发者微信号(原始ID)
         $crateTime = time();
         $msgType = “text”;
         $template=”
                <xml>
               
<ToUserName><![CDATA[%s]]></ToUserName>
               
<FromUserName><![CDATA[%s]]></FromUserName>
                <CreateTime>%s</CreateTime>
               
<MsgType><![CDATA[%s]]></MsgType>
               
<Content><![CDATA[%s]]></Content>
                </xml>”;
                $info =
sprintf($template,$toUserName,$fromUserName,$crateTime,$msgType,$content);
                echo $info; 
    }

                       $fromUser = $postObj->toUserName;

//当微信用户发送imooc,公众账号回复‘imooc is very good’
/*<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
<FromUserName><![CDATA[fromUser]]></FromUserName>
<CreateTime>12345678</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[你好]]></Content>
</xml>*/
/*if(strtolower($postObj->MsgType) == ‘text’){
switch( trim($postObj->Content) ){
case 1:
$content = ‘您输入的数字是1’;
break;
case 2:
$content = ‘您输入的数字是2’;
break;
case 3:
$content = ‘您输入的数字是3’;
break;
case 4:
$content = “<a href=’;”;
break;
case ‘英文’:
$content = ‘imooc is ok’;
break;

}

                        $time    = time();

}
$template = “<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>”;
//注意模板中的中括号 无法少 也不可以多
$fromUser = $postObj->ToUserName;
$toUser = $postObj->FromUserName;
$time = time();
// $content = ‘18723180099’;
$msgType = ‘text’;
echo sprintf($template, $toUser, $fromUser, $time, $msgType,
$content);

实际那个model类就是一个并入的sdk,一些通用的艺术都放在那里,不用每一遍都写四回,比如回复文本信息,回复图文音信,回复图片新闻,那里贴出的只是过来文本音讯

                        $msgType  = ‘text’;

}
}
*/
//用户发送tuwen1关键字的时候,回复一个单图文
if( strtolower($postObj->MsgType) == ‘text’ &&
trim($postObj->Content)==’tuwen2′ ){
$toUser = $postObj->FromUserName;
$fromUser = $postObj->ToUserName;
$arr = array(
array(
‘title’=>’imooc’,
‘description’=>”imooc is very cool”,
‘picUrl’=>”,
‘url’=>”,
),
array(
‘title’=>’hao123’,
‘description’=>”hao123 is very cool”,
‘picUrl’=>”,
‘url’=>”,
),
array(
‘title’=>’qq’,
‘description’=>”qq is very cool”,
‘picUrl’=>”,
‘url’=>”,
),
);
$template = “<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<ArticleCount>”.count($arr).”</ArticleCount>
<Articles>”;
foreach($arr as $k=>$v){
$template .=”<item>
<Title><![CDATA[“.$v[‘title’].”]]></Title>
<Description><![CDATA[“.$v[‘description’].”]]></Description>
<PicUrl><![CDATA[“.$v[‘picUrl’].”]]></PicUrl>
<Url><![CDATA[“.$v[‘url’].”]]></Url>
</item>”;
}

的方法。

                        $content  = ‘欢迎关怀大家的微信公众号’;

$template .=”</Articles>
</xml> “;
echo sprintf($template, $toUser, $fromUser, time(), ‘news’);

                        $template = “<xml>

//注意:举办多图文发送时,子图文个数不可以当先10个
}else{
switch( trim($postObj->Content) ){
case 1:
$content = ‘您输入的数字是1’;
break;
case 2:
$content = ‘您输入的数字是2’;
break;
case 3:
$content = ‘您输入的数字是3’;
break;
case 4:
$content = “<a href=’;”;
break;
case ‘英文’:
$content = ‘imooc is ok’;
break;
}
$template = “<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[%s]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>”;
//注意模板中的中括号 不可以少 也不可以多
$fromUser = $postObj->ToUserName;
$toUser = $postObj->FromUserName;
$time = time();
// $content = ‘18723180099’;
$msgType = ‘text’;
echo sprintf($template, $toUser, $fromUser, $time, $msgType,
$content);

                                             
<ToUserName><![CDATA[%s]]</ToUserName>

}//if end
}//reponseMsg end

                                             
<FromUserName><![CDATA[%s]]></FromUserName>

function http_curl(){
//获取imooc
//1.初始化curl
$ch = curl_init();
$url = ”;
//2.设置curl的参数
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//3.采集
$output = curl_exec($ch);
//4.关闭
curl_close($ch);
var_dump($output);
}

                                             
<CreateTime>%s</CreateTime>

function getWxAccessToken(){
//1.请求url地址
$appid = ‘wx08d5c2cb632bb5e4’;
$appsecret = ’06d3444fb9abd8d00314eb4a38ad61a8′;
$url =
“;
//2初始化
$ch = curl_init();
//3.设置参数
curl_setopt($ch , CURLOPT_www.5929.com,URL, $url);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, 1);
//4.调用接口
$res = curl_exec($ch);
//5.关闭curl
curl_close( $ch );
if( curl_errno($ch) ){
var_dump( curl_error($ch) );
}
$arr = json_decode($res, true);
var_dump( $arr );
}

                                             
<MsgType><![CDATA[%s]]<MsgType>

function getWxServerIp(){
$accessToken =
“6vOlKOh7r5uWk_ZPCl3DS36NEK93VIH9Q9tacreuxJ5WzcVc235w_9zONy75NoO11gC9P0o4FBVxwvDiEtsdX6ZRFR0Lfs_ymkb8Bf6kRfo”;
$url =
“;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$res = curl_exec($ch);
curl_close($ch);
if(curl_errno($ch)){
var_dump(curl_error($ch));
}
$arr = json_decode($res,true);
echo “<pre>”;
var_dump( $arr );
echo “</pre>”;

                                             
 <Content><![CDATA[%s]]</Content>

}
}//class end

                                               </xml>”;

           $info    = sprintf( $template, $toUser, $fromUser, $time,
$msgType, $content );

            }

    }

}

Leave a Comment.