码迷,mamicode.com
首页 > 微信 > 详细

微信JS-SDK加载验证流程

时间:2015-06-13 18:49:43      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:微信js-sdk

参考链接:http://blog.bwphp.cn/?p=617

<?php
$appid = "wx69ee1b32fb7e9121";
$secret = "b5606c679038148d6e858687bc830a18";
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
 
$res = file_get_contents($url);
$data = json_decode($res);
var_dump($data->access_token);
 
$jsapi_ticket_json = file_get_contents(‘https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=‘.$data->access_token.‘&type=jsapi‘);
$jsapi_ticket_obj = json_decode($jsapi_ticket_json);
$jsapi_ticket = $jsapi_ticket_obj->ticket;
$noncestr = ‘qwertyuiop‘;
$timestamp = time();
 
$signature = sha1(sprintf(‘jsapi_ticket=‘.$jsapi_ticket.‘&noncestr=‘.$noncestr.‘&timestamp=‘.$timestamp.‘&url=http://zhangsixia.bwphp.cn/wei1.php‘));
echo $signature;
?>
 
<script src=‘http://res.wx.qq.com/open/js/jweixin-1.0.0.js‘></script>
<script type="text/javascript">
wx.config({
        debug: true,
        appId: ‘<?php echo $appid; ?>‘,
        timestamp: <?php echo $timestamp; ?>,
        nonceStr: ‘<?php echo $noncestr; ?>‘,
        signature: ‘<?php echo $signature; ?>‘,
        jsApiList: [‘uploadImage‘,‘downloadImage‘]
});
 
wx.ready(function(){
        wx.checkJsApi({
                jsApiList: [‘chooseImage‘],
                success: function(res) {}
        });
        wx.chooseImage({
                success: function (res) {
                        var localIds = res.localIds;
                }
        });
});
wx.error(function(res){
    alert(‘no‘);
});
</script>


微信JS-SDK加载验证流程

标签:微信js-sdk

原文地址:http://pilipala.blog.51cto.com/10165737/1661522

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