js share function

$confinfo = $this->js_sdk("wx3bd22c50ac87af81","1289bab67c6de6c327160349b85d8de0"); //千化
        $this->assign("confinfo",$confinfo);
    protected function js_sdk($appid,$appsecret){
        $protocol = (!empty($_SERVER[‘HTTPS‘]) && $_SERVER[‘HTTPS‘] !== off || $_SERVER[‘SERVER_PORT‘] == 443) ? "https://" : "http://";
        $url = $protocol.$_SERVER[‘HTTP_HOST‘].$_SERVER[‘REQUEST_URI‘];
        $api_url="http://api.4vtk.com/wx_js_sdk.php?appid=$appid&appsecret=$appsecret";
        $result =file_get_contents($api_url);
        $jsoninfo = json_decode($result, true);
        $jsapiTicket=$jsoninfo["jsapiTicket"];
        $argu = array();
        $argu[‘appId‘] = $appid;
        $argu[‘url‘] = $url;
        $argu[‘nonceStr‘] = $this->createNonceStr();
        $argu[‘timestamp‘] = time();
        $argu[‘jsapi_ticket‘] = $jsapiTicket;
        $string = "jsapi_ticket=".$argu[jsapi_ticket]."&noncestr=".$argu[nonceStr]."&timestamp=".$argu[timestamp]."&url=".$argu[url];
        $argu[‘signature‘] = sha1(trim($string));
        return $argu;
    }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。