码迷,mamicode.com
首页 > Web开发 > 详细

js share function

时间:2015-05-20 17:41:00      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

$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;
    }

 

js share function

标签:

原文地址:http://www.cnblogs.com/yutaoyao/p/4517494.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!