本文整理汇总了PHP中wechatCallbackapiTest::valid方法的典型用法代码示例。如果您正苦于以下问题:PHP wechatCallbackapiTest::valid方法的具体用法?PHP wechatCallbackapiTest::valid怎么用?PHP wechatCallbackapiTest::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wechatCallbackapiTest
的用法示例。
在下文中一共展示了wechatCallbackapiTest::valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
/**
* 合法性验证
* 文档地址:http://mp.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E5%85%A5%E6%8C%87%E5%8D%97
*/
function _yanzhengAct()
{
define("TOKEN", "cailai123");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
exit;
}
示例2: valid
<?php
/**
* wechat php test
*/
//define your token
define("TOKEN", "baigungun");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
//valid signature , option
if ($this->checkSignature()) {
echo $echoStr;
exit;
}
}
public function responseMsg()
{
//get post data, May be due to the different environments
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
//extract post data
if (!empty($postStr)) {
/* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
the best way is to check the validity of xml by yourself */
libxml_disable_entity_loader(true);
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUsername = $postObj->FromUserName;
示例3: index
public function index()
{
/*{{{*/
$wechatObj = new wechatCallbackapiTest();
if (isset($_GET['echostr'])) {
$wechatObj->valid();
} else {
$wechatObj->responseMsg();
}
}