#1 xpp1000
地址栏地址很长的时候,就不能用get或者request或this->spArgs()得到变量
2015-10-12 17:04:23
#4 jake
框架没有对这种东西进行限制的,有什么意义吗?对吧?
而且代码也在哪儿,开源的随时可以查。
很多次也遇到这种“框架是不是做了XXX限制,明明没用框架就不会”,
然后给到代码来检查的时候,最终发现不外以下几种情况:
1. 用错了
2. 没检查好自己的代码。
3. 搞错了
所以如果发现这种情况,建议是上传代码给大家进行检查。
都是程序员,最好用代码说话。
2015-10-12 18:14:17
#5 xpp1000
class wxapi {
public function valid()
{
$echoStr = $_GET["echostr"];
//valid signature , option
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
function test()
{echo '123';
}
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;
$toUsername = $postObj->ToUserName;
$keyword = trim($postObj->Content);
$time = time();
$textTpl = "
%s
0
";
if(!empty( $keyword ))
{
$msgType = "text";
$contentStr = "Welcome to wechat world!";
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultStr;
}else{
echo "Input something...";
}
}else {
echo "";
exit;
}
}
public function checkSignature()
{
// you must define TOKEN by yourself
if (!defined("TOKEN")) {
throw new Exception('TOKEN is not defined!');
}
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
//echo $_SERVER['REMOTE_ADDR'];
//echo $signature;
//echo $timestamp;
$token = TOKEN;
$tmpArr = array($token, $timestamp, $nonce);
// use SORT_STRING rule
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
return true;
}else{
return false;
}
}
}
2015-10-12 18:29:43
#6 xpp1000
这个是微信的一管方例子,我放在根目录,然后在程序中引用
ob_start();
header("Content-type: text/html; charset=utf-8");
ob_end_flush();
include("wxapi.php");
class main extends spController
{
function wx()
{
$wx =spclass("wxapi");
$wx->valid();
//$wx->test();
//$dat=$this->spArgs();
}
{
2015-10-12 18:32:41
#8 jake
看不懂,微信接口没做过。
只是之前见过两三次有朋友用SP做微信的东东而已。
没听说过框架有限制微信的GET,我自己写框架代码的时候也没发现代码有这样的功能,如果你能找到那就太好了。
2015-10-12 22:29:12
#9 冈刀飞絮
1、检查微信公众号平台填的地址是否对(看你这个 应该 ?c=main&a=weixin地址)
2、微信首次验证要保证token 相同看下token是否相同
3、上面都检查没问题以后 可以写下 日志记录下微信服务器向你服务器的请求 相关内容 调试下就ok了
4、到第三点 问题肯定能找到 (不管什么问题觉得不会是应为sp框架导致的,sp本身没做什么的,我用llaravel 那么重的框架开发微信公众号也没用任何限制的)
2015-10-17 00:19:52