Example #1
0
 /**
  * 获取消息接收数量信息
  * @param unknown $receivedVO
  * 备注:发送采用https需要修改php.ini打开extension=php_openssl.dll
  * 
  */
 public function getReceivedData($receivedVO, $revResult)
 {
     //echo "1111";
     //加密字符串
     $secretEncode = new SecretEncode();
     $authStr = $secretEncode->getBase64Encode($receivedVO->getAuthStr());
     $receivedVO->setAuth($authStr);
     //url
     $url = $this->RECEIVE_API_URL . "?" . $receivedVO->getParams();
     $header = 'Authorization: Basic ' . $receivedVO->getAuth();
     //请求头信息
     $context = array('http' => array('method' => 'GET', 'header' => $header));
     $stream_context = stream_context_create($context);
     //echo $stream_context;
     $httpPostClient = new HttpPostClient();
     $code = 200;
     try {
         $rs = $httpPostClient->request_tools($url, $stream_context);
         //echo $rs;
     } catch (Exception $e) {
         echo $e;
         $code = 404;
     }
     //echo $rs["body"];
     $revResult->setResultStr($rs, $code);
     //echo $revResult->getResultStr();
     return $revResult;
 }
Example #2
0
 /**
  * 发送主体
  * @param SendVO    $sendVO  发送信息对象
  */
 public function pushMsg($sendVO, $msgResult)
 {
     //加密字符串
     $secretEncode = new SecretEncode();
     $verificationCode = $secretEncode->getMD5Encode($sendVO->getVerification_code());
     $sendVO->setVerification_code($verificationCode);
     //获取参数
     $params = $sendVO->getParams();
     // 		echo "*********".$params."\n ###";
     $context = array();
     $context['http'] = array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $params);
     // 		echo ($params);
     // 		exit;
     $stream_context = stream_context_create($context);
     //         var_dump($context);;exit;
     //echo $stream_context."\n";
     $httpPostClient = new HttpPostClient();
     $code = 200;
     try {
         $rs = $httpPostClient->request_tools($this->SEND_API_URL, $stream_context);
     } catch (Exception $e) {
         $code = 404;
     }
     $msgResult->setResultStr($rs, $code);
     return 0;
 }