<?php include_once 'secken.class.php'; $app_id = '1234'; $app_key = 'app_key'; $auth_id = 'auth_id'; // Create an API object using your credentials $secken_api = new secken($app_id, $app_key, $auth_id); # Step 1 - Get an qrcode for binding $ret = $secken_api->getBinding(); //$ret = $secken_api->offline_auth('2121','sd'); # Step 2 - Check the returned result if ($secken_api->getCode() != 200) { var_dump($secken_api->getCode(), $secken_api->getMessage()); } else { var_dump($ret); }
<?php include_once 'secken.class.php'; $app_id = 'IXgdZ1A7CFUej2ytUbVjFJKS5ICiorw4'; $app_key = 'ELD0DNzMYep7m6Uo1v3v'; $secken_api = new secken($app_id, $app_key); if ($_GET["Action"] == "GetYcAuthQrCode") { $ret = $secken_api->getQrCode(3); if ($secken_api->getCode() != 200) { $arr = array('status' => $secken_api->getCode(), 'description' => $secken_api->getMessage()); $json = json_encode($arr); echo $json; } else { $json = json_encode($ret); echo $json; } return; } if ($_GET["Action"] == "CheckYcAuthResult") { $event_id = $_GET["eid"]; $ret = $secken_api->getResult($event_id); if ($secken_api->getCode() != 200) { //var_dump($secken_api->getCode(), $secken_api->getMessage()); $arr = array('status' => $secken_api->getCode(), 'description' => $secken_api->getMessage()); $json = json_encode($arr); echo $json; } else { $json = json_encode($ret); echo $json; } return;
<?php define('SDK_DIR', dirname(dirname(dirname(__FILE__)))); include_once SDK_DIR . '/secken.class.php'; //填写洋葱网给您申请的app_id $app_id = 'ZD8LszdeFa2l3hsgiE7WFJPkU6QjXGuQ'; //填写您在洋葱网申请的app_key $app_key = '3BTU56UYKIMJ89aqNurK'; //填写您在洋葱网申请的auth_id $auth_id = 'e8QCNSc5P6WOzdvut4rh'; //实例化洋葱认证类 $secken_api = new secken($app_id, $app_key, $auth_id); $ac = isset($_GET['ac']) ? $_GET['ac'] : 'none'; //发起验证请求 if ($ac == 'qrcode_for_auth') { # Step 1 - Get an qrcode for binding $resp = $secken_api->getAuth(); echo json_encode($resp); } //获取事件结果 if ($ac == 'event_result') { $event_id = isset($_GET['event_id']) ? $_GET['event_id'] : ''; $resp = $secken_api->getResult($event_id); if (is_array($resp)) { $resp['description'] = $secken_api->getMessage(); } echo json_encode($resp); }
<?php include_once 'secken.class.php'; //填写洋葱网给您申请的app_id $app_id = 'ZD8LszdeFa2l3hsgiE7WFJPkU6QjXGuQ'; //填写您在洋葱网申请的app_key $app_key = '3BTU56UYKIMJ89aqNurK'; //填写您在洋葱网申请的auth_id $auth_id = 'e8QCNSc5P6WOzdvut4rh'; // Create an API object using your credentials $secken_api = new secken($app_id, $app_key, $auth_id); # Step 1 - Get an qrcode for binding $ret = $secken_api->getAuth(1, "https://callback.com/path"); //$ret = $secken_api->realtimeAuth('uid', 1, 1, 'https://callback.com/path', '123.123.123.123', '名字'); //$ret = $secken_api->offline_auth('2121','sd'); # Step 2 - Check the returned result if ($secken_api->getCode() != 200) { var_dump($secken_api->getCode(), $secken_api->getMessage()); } else { var_dump($ret); }
<?php if (!defined('IN_DISCUZ')) { exit('Access Denied'); } require_once 'language.' . currentlang() . '.php'; require_once DISCUZ_ROOT . './source/plugin/yangcong/secken.class.php'; $app_id = $_G['cache']['plugin']['yangcong']['appid']; $app_key = $_G['cache']['plugin']['yangcong']['appkey']; $auth_id = $_G['cache']['plugin']['yangcong']['auth_id']; $yangcong = new secken($app_id, $app_key, $auth_id); $bindhash = isset($_POST['handlekey']) ? trim($_POST['handlekey']) : 'L' . random(4); //进行绑定请求 if (submitcheck('confirmsubmit')) { //查询详细事件信息 $info = $yangcong->getResult($_POST['event_id']); if (!empty($info['uid'])) { $bind_info = C::t('#yangcong#yangcong')->getBindInfo($_G['uid'], $info['uid']); //如果已经绑定,跳转到解绑页面 if (!empty($bind_info['uid'])) { showmessage($lang['has_bind'], 'home.php?mod=spacecp&ac=plugin&id=yangcong:binding', null, array('alert' => 'info', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0)); } //更新绑定纪录 if (!empty($bind_info['uid'])) { C::t('#yangcong#yangcong')->updateBindInfo($_G['uid'], $info['uid']); } else { $data = array(); $data = array('uid' => $_G['uid'], 'yangcong' => $info['uid']); C::t('#yangcong#yangcong')->insertBindInfo($data); } showmessage($lang['bind_success'], 'home.php?mod=spacecp&ac=plugin&id=yangcong:binding', null, array('alert' => 'info', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1));
<?php include_once 'secken.class.php'; // login YangCong Developer Center, A new sdk application can be created in secken Dashboard, you can get appid、 appkey $app_id = 'app_id'; $app_key = 'app_key'; // Create an API object using your credentials $secken_api = new secken($app_id, $app_key); # Step 1 - Get an qrcode for binding $ret = $secken_api->getQrCode(1, "test", "action to pay", "https://callback.com/path"); //$ret = $secken_api->askPushAuth('zhangsan', 1, "test","action to delete", 'https://callback.com/path'); //$ret = $secken_api->checkAuthToken('asdfh34dgvfhy6gfg45vcv'); # Step 2 - Check the returned result if ($secken_api->getCode() != 200) { $arr = array('status' => $secken_api->getCode(), 'description' => $secken_api->getMessage()); $json = json_encode($arr); echo $json; } else { $json = json_encode($ret); echo $json; }
<?php if (!defined('IN_DISCUZ')) { exit('Access Denied'); } require_once 'language.' . currentlang() . '.php'; require_once DISCUZ_ROOT . './source/plugin/yangcong/secken.class.php'; $app_id = $_G['cache']['plugin']['yangcong']['appid']; $app_key = $_G['cache']['plugin']['yangcong']['appkey']; $auth_id = $_G['cache']['plugin']['yangcong']['auth_id']; $yangcong = new secken($app_id, $app_key, $auth_id); $loginhash = isset($_POST['handlekey']) ? trim($_POST['handlekey']) : 'L' . random(4); //登陆验证 if (submitcheck('confirmsubmit')) { $info = $yangcong->getResult($_POST['event_id']); $code = $yangcong->getCode(); if ($code == 200) { $var = C::t('#yangcong#yangcong')->getUid($info['uid']); if (!empty($var)) { $uid = $var['uid']; if ($uid) { $member = getuserbyuid($uid, 1); dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), 31536000); showmessage($lang['login_success'], null, null, array('alert' => 'info', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1)); } else { showmessage($lang['login_failed'], null, null, array('alert' => 'error', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0)); } } else { // $auth = authcode($info['uid'], 'ENCODE', $_G['config']['security']['authkey']); // dsetcookie('yangconguid', $auth); showmessage($lang['unbind'], 'member.php?mod=register', null, array('alert' => 'error', 'msgtype' => 3, 'showmsg' => 1, 'handle' => 0, 'showdialog' => 1, 'locationtime' => 1));
<?php require dirname(__FILE__) . '/secken.class.php'; require dirname(__FILE__) . '/load_config.php'; $app_id = $GLOBALS['yangcong']['app_id']; $app_key = $GLOBALS['yangcong']['app_key']; $auth_id = $GLOBALS['yangcong']['auth_id']; $yangcong = new secken($app_id, $app_key, $auth_id); $user_id = $_SESSION['user_id']; if (empty($user_id)) { show_message('请先登录', 'user.php?act=login', 'user.php?act=login'); } //进行绑定请求 if (!empty($_POST['event_id'])) { //查询详细事件信息 $info = $yangcong->getResult($_POST['event_id']); if (!empty($info['uid'])) { $sql = "select `uid` from %s where `uid` = %d AND `yangcong` = '%s'"; $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $user_id, $info['uid']); $var = $GLOBALS['db']->getRow($sql); //如果已经绑定,跳转到解绑页面 if (!empty($var['uid'])) { die(json_encode(array('status' => 0, 'message' => '账号已经绑定', 'url' => 'plugin.php?act=yangcong_bind'))); } //更新绑定纪录 $table = $GLOBALS['ecs']->table('yangcong'); if (!empty($var['uid'])) { $fields = array('yangcong' => $info['uid']); $GLOBALS['db']->autoExecute($table, $fields, 'UPDATE', "uid={$user_id}"); } else { $fields = array('uid' => $user_id, 'yangcong' => $info['uid']);
<?php require dirname(__FILE__) . '/secken.class.php'; require dirname(__FILE__) . '/load_config.php'; $app_id = $GLOBALS['yangcong']['app_id']; $app_key = $GLOBALS['yangcong']['app_key']; $auth_id = $GLOBALS['yangcong']['auth_id']; $yangcong = new secken($app_id, $app_key, $auth_id); $user_id = $_SESSION['user_id']; if (empty($user_id)) { show_message('请先登录', 'user.php?act=login', 'user.php?act=login'); } if (!empty($_POST['event_id'])) { $info = $yangcong->getResult($_POST['event_id']); if (!empty($info['uid'])) { $sql = "DELETE FROM %s WHERE uid=%d AND yangcong='%s'"; $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $user_id, $info['uid']); $GLOBALS['db']->query($sql); die(json_encode(array('status' => 1, 'message' => '绑定取消成功', 'url' => 'plugin.php?act=yangcong_bind'))); } else { if ($yangcong->getCode() == 602) { die(json_encode(array('status' => 0, 'message' => '请求已推送到您的洋葱App,请打开确认'))); } else { die(json_encode(array('status' => 0, 'message' => $yangcong->getMessage()))); } } } else { $sql = "select * from %s where `uid` = %d"; $sql = sprintf($sql, $GLOBALS['ecs']->table('yangcong'), $user_id); $yangcong_info = $GLOBALS['db']->getRow($sql); $yangcong_uid = !empty($yangcong_info) ? $yangcong_info['yangcong'] : '';