更新代码
This commit is contained in:
36
app/Api/Controllers/MessageController.php
Normal file
36
app/Api/Controllers/MessageController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Api\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MessageController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$echoStr = $_GET["echostr"];
|
||||
if (self::checkSignature()) {
|
||||
echo $echoStr;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function checkSignature()
|
||||
{
|
||||
|
||||
$signature = $_GET["signature"];
|
||||
$timestamp = $_GET["timestamp"];
|
||||
$nonce = $_GET["nonce"];
|
||||
$token = 'BiX5ygs8lIOP6EtrKF6kCktebp7rWgzy';
|
||||
$tmpArr = array($token, $timestamp, $nonce);
|
||||
sort($tmpArr, SORT_STRING);
|
||||
$tmpStr = implode($tmpArr);
|
||||
$tmpStr = sha1($tmpStr);
|
||||
if ($tmpStr == $signature) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user