当前位置: 首页>>代码示例>>PHP>>正文


PHP Wechat::getJsTicket方法代码示例

本文整理汇总了PHP中Wechat::getJsTicket方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::getJsTicket方法的具体用法?PHP Wechat::getJsTicket怎么用?PHP Wechat::getJsTicket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wechat的用法示例。


在下文中一共展示了Wechat::getJsTicket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showTip

function showTip($smarty, $tip, $db, $title)
{
    $options = array('token' => WX_TOKEN, 'appid' => WX_APPID, 'encodingaeskey' => '6pnP7qHyqJ1kFXMjuO4Z3QrpOa9WfapsgkPOtXoZKC2', 'appsecret' => WX_SECRET, 'logcallback' => logdebug);
    $we = new Wechat($options);
    $auth = $we->checkAuth();
    $js_ticket = $we->getJsTicket();
    $smarty->assign('tip', $tip);
    $smarty->assign('title', $title);
    $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $smarty->assign('js_sign', $we->getJsSign($url));
    $smarty->display('templates/tip.html');
    $db->disconnect();
    die;
}
开发者ID:xuhongxu96,项目名称:Tagexing,代码行数:14,代码来源:main.php

示例2: Wechat

<?php

// WP_Wechat Handle
$wechat = new WP_Wechat();
// wechat-php-sdk Handle
$we = new Wechat(array('appsecret' => $wechat->app_secret, 'appid' => $wechat->app_id));
$auth = $we->checkAuth();
$js_ticket = $we->getJsTicket();
if (!$js_ticket) {
    $errcode = $we->errCode;
    $errtext = ErrCode::getErrText($weObj->errCode);
    echo "获取 js_ticket 失败! 错误码:{$errcode} 错误原因:{$errtext} ";
}
$https = isset($_SERVER['HTTPS']) && 'on' === $_SERVER['HTTPS'];
$url = ($https ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$js_sign = $we->getJsSign($url);
?>

<script>
    if(window.wx) {
        wx.config({
            debug: /debug=1/.test(location.href),
            appId: '<?php 
echo $js_sign['appId'];
?>
', // 必填,公众号的唯一标识
            timestamp: <?php 
echo $js_sign['timestamp'];
?>
, // 必填,生成签名的时间戳,切记时间戳是整数型,别加引号
            nonceStr: '<?php 
开发者ID:EaseCloud,项目名称:WP-Wechat,代码行数:31,代码来源:header-jssdk.php

示例3: json_encode

<?php

include "../qy-sdk/wechat.class.php";
require 'api_rb.php';
require 'api_db.php';
$url = isset($_REQUEST['url']) ? $_REQUEST['url'] : '';
$timestamp = time();
$noncestr = 'Gds_Wechat_CSC_V2';
// Log
_log(json_encode(['url' => $url, 'timestamp' => $timestamp, 'noncestr' => $noncestr]));
// Check
if (empty($url)) {
    header('Content-type:text/json;charset=utf-8');
    echo json_encode(['result' => 'failed', 'error' => 'missing argument']);
    die;
}
// Get Ticket and Sign
$options = ['token' => 'nizhidaoma', 'encodingaeskey' => 'xc8rRK4iOQjTJK9hOYhRrC9sPBJvF5Jhjq203iMC7vF', 'appid' => 'wxe85832e232e73f41', 'appsecret' => '4c8f1aa381675dd2569fc9482052afdc', 'debug' => true, 'logcallback' => '_log'];
$weObj = new Wechat($options);
$jsTicket = $weObj->getJsTicket();
$jsSign = $weObj->getJsSign($url, $timestamp, $noncestr);
// Return
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'true', 'sign' => $jsSign]);
die;
开发者ID:adexbn,项目名称:gds_wechat,代码行数:25,代码来源:api_js.php


注:本文中的Wechat::getJsTicket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。