<commit_before><?php

namespace App\Helpers;

use App\Events\WechatApiEvent;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\URL;
use Mockery\Exception;


class WeChatConfig
{


    public function getSignPackage($cur_url = null)
    {
        $jsapiTicket = $this->getJsApiTicket();
        // 注意 URL 一定要动态获取，不能 hardcode.

        if (!empty($_SERVER['SERVER_PORT'])) {
            $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";

            $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

        } else {
            $url = env('APP_URL');
        }

        $timestamp = time();
        $nonceStr = $this->createNonceStr();

        // 这里参数的顺序要按照 key 值 ASCII 码升序排序
        $string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";

        $signature = sha1($string);

        $signPackage = array(
            "appId" => env('WECHAT_APPID'),
            "nonceStr" => $nonceStr,<commit_msg>access token bug fix<commit_after><?php

namespace App\Helpers;

use App\Events\WechatApiEvent;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\URL;
use Mockery\Exception;


class WeChatConfig
{


    public function getSignPackage($cur_url = null)
    {
        $jsapiTicket = $this->getJsApiTicket();
        // 注意 URL 一定要动态获取，不能 hardcode.

        try {
            $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";

            if (empty($cur_url))
                $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
            else
                $url = $cur_url;
        }catch (Exception $e){
            info('获取微信配置出错，错误信息【:'.$e->getMessage().'】');
            $url = env('APP_URL');
        }

        $timestamp = time();
        $nonceStr = $this->createNonceStr();

        // 这里参数的顺序要按照 key 值 ASCII 码升序排序
        $string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";

        $signature = sha1($string);

        $signPackage = array(
            "appId" => env('WECHAT_APPID'),
            "nonceStr" => $nonceStr,
{'fraction_non_alphanumeric': 0.1625441696113074, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 2.6650485436893203, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '747227', 'n_tokens_mistral': 785, 'n_tokens_neox': 791, 'n_words': 127}