efps-version
parent
f80b66f3ba
commit
8e0ab3f46c
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Helper\Platform;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Hyperf\Guzzle\CoroutineHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
|
||||
class Notification
|
||||
{
|
||||
public static function post($url, $params): BaseClient {
|
||||
$client = new Client([
|
||||
'handler' => HandlerStack::create(new CoroutineHandler()),
|
||||
'timeout' => 5,
|
||||
'swoole' => [
|
||||
'timeout' => 10,
|
||||
'socket_buffer_size' => 1024 * 1024 * 2,
|
||||
],
|
||||
]);
|
||||
$response = $client->request('POST', $url, [
|
||||
'json' => $params
|
||||
]);
|
||||
return (string)$response->getBody();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Helper\Platform;
|
||||
|
||||
class Signer
|
||||
{
|
||||
public static function sign($params, $secretKey) {
|
||||
$signString = $params['app_id'] . '&'
|
||||
. $params['timestamp'] . '&'
|
||||
. $params['nonce_str'] . '&'
|
||||
. $params['data'] . '&'
|
||||
. $secretKey;
|
||||
return md5($signString);
|
||||
}
|
||||
|
||||
public static function verify($params, $secretKey) {
|
||||
$sign = self::sign($params, $secretKey);
|
||||
return $sign == $params['sign'];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue