本文整理汇总了PHP中Wechat::checkAuth方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::checkAuth方法的具体用法?PHP Wechat::checkAuth怎么用?PHP Wechat::checkAuth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wechat
的用法示例。
在下文中一共展示了Wechat::checkAuth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: array
<?php
require_once '../config.php';
require_once '../db.php';
require_once '../wechat.class.php';
$options = array('token' => WX_TOKEN, 'appid' => WX_APPID, 'appsecret' => WX_SECRET, 'debug' => false, 'logcallback' => 'logdebug');
$weObj = new Wechat($options);
$weObj->checkAuth();
$ret = $weObj->getQRCode($_GET['id'], 1);
$url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . urlencode($ret['ticket']);
echo "<img src='{$url}' /><a href='{$url}'>View in new page</a>";
示例3: 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
示例4: check_auth
/**
* 获取access_token的接口
* @return [type] [description]
*/
public function check_auth()
{
$appid = I('get.appid');
$appsecret = I('get.appsecret');
if (empty($appid) || empty($appsecret)) {
echo json_encode(array('errmsg' => '信息不完整,请提供完整信息', 'errcode' => 1));
exit;
}
$config = $this->model->table('wechat')->field('token, appid, appsecret')->where('appid = "' . $appid . '" and appsecret = "' . $appsecret . '" and status = 1')->find();
if (empty($config)) {
echo json_encode(array('errmsg' => '信息错误,请检查提供的信息', 'errcode' => 1));
exit;
}
$obj = new Wechat($config);
$access_token = $obj->checkAuth();
if ($access_token) {
echo json_encode(array('access_token' => $access_token, 'errcode' => 0));
exit;
} else {
echo json_encode(array('errmsg' => $obj->errmsg, 'errcode' => $obj->errcode));
exit;
}
}
示例5: DB
<?php
require_once '../config.php';
require_once '../function.php';
require_once '../db.php';
require_once '../wechat.class.php';
if ($_GET['p'][4] != ':') {
$db = new DB();
$db->connect();
$weObj = new Wechat();
$weObj->checkAuth(WX_APPID, WX_SECRET);
echo "<img src='" . $weObj->getMediaURL($_GET['p']) . "'>";
$db->disconnect();
} else {
echo "<a href='" . $_GET['p'] . "'>" . $_GET['p'] . "</a><br>请复制链接查看原图,或打开链接后在地址栏回车重新打开。(刷新无用)";
}
示例6: array
<?php
/**
* Created by PhpStorm.
* User: run
* Date: 2015/7/15
* Time: 11:36
*/
include "wechat.class.php";
$options = array('token' => 'vonvon', 'encodingaeskey' => 'encodingaeskey', 'appid' => 'wx519f23f4a45e8c37', 'appsecret' => 'ea8f0b17b3a0882bf5fda7ed27758482');
$weObj = new Wechat($options);
$weObj->valid();
//明文或兼容模式可以在接口验证通过后注释此句,但加密模式一定不能注释,否则会验证失败
$openid = $weObj->getRev()->getRevFrom();
$token = $weObj->checkAuth();
$info = $weObj->getUserInfo($openid);
$type = $weObj->getRev()->getRevType();
switch ($type) {
case Wechat::MSGTYPE_TEXT:
$content = $weObj->getRev()->getRevContent();
if (substr($content, 0, 6) == '姓名') {
$name = substr($content, 6);
$res = array("0" => array('Title' => $name . ', 你的生辰八字', 'Description' => 'Vonvon作为国际化的SNS社交媒体,从2015年1月起,在全世界已经拥有1亿以上的 用户。现在已在韩国,中国,台湾,泰国,越南,印尼,美国,巴西,西班牙等国家 开放。将来会拓展到更多的国家,并且会创作更多有趣的主题测试。', 'PicUrl' => 'http://cdn-cn-static-dr.vonvon.net/images/cn/recruit_main.jpg', 'Url' => 'http://cn.vonvon.net/'));
$weObj->news($res)->reply();
} else {
$weObj->text("Your nickname is " . $info['nickname'] . "\nYour sex is " . $info['sex'] . "\nYour city is " . $info['city'] . "\nYour province is " . $info['province'] . "\n Your country is " . $info['country'] . "\nYour headimgurl is " . $info['headimgurl'] . "\nYour subscribe_time is " . date("Y-m-d H:i:s", $info['subscribe_time']) . "\nNow is " . date("Y-m-d H:i:s", time()))->reply();
exit;
}
break;
case Wechat::MSGTYPE_EVENT:
$event = $weObj->getRev()->getRevEvent();