function getaccesstoken($appid, $appsecret) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret; $result = https_request($url); $jsoninfo = json_decode($result, true); $access_token = $jsoninfo["access_token"]; return $access_token; }
public function test() { $url = __ROOT__ . '/getWxInfo.php'; $arr = https_request($url); p($arr); die; }
public function ip() { $ip = $this->input->get('ip', TRUE); $result = https_request("http://ipapi.sinaapp.com/api.php?f=json&ip={$ip}"); $data = json_decode($result, true); echo $data['area1']; }
function get_token() { $appid = "wx8f0a915f08327903"; $appsecret = "d4624c36b6795d1d99dcf0547af5443d"; $curl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $tokendata = https_request($curl); $arrtoken = json_decode($tokendata, true); return $arrtoken["access_token"]; }
function getSubscribe($appid, $appsecret, $openid) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $accessToken = https_request($url); $accessToken = json_decode($accessToken, true); $token = $accessToken['access_token']; $dingyue_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}&lang=zh_CN"; $dingyue_json = https_request($dingyue_url); return json_decode($dingyue_json, true); }
function getwuserinfo($postObj, $appid, $appsecret) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $result = https_request($url); $jsoninfo = json_decode($result, true); $access_token = $jsoninfo["access_token"]; $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $postObj->FromUserName . "&lang=zh_CN"; $wuser = https_request($url); $wuser = json_decode($wuser, true); return $wuser; }
function get_userinfo($code, $cfg) { //====获取access_token $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $cfg['appid'] . "&secret=" . $cfg['appsecret'] . "&code=" . $code . "&grant_type=authorization_code"; $access_token_result = https_request($access_token_url); $access_token_arr = json_decode($access_token_result, true); //====获取用户信息 $userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token_arr['access_token'] . "&openid=" . $access_token_arr['openid']; $userinfo_result = https_request($userinfo_url); $userinfo_arr = json_decode($userinfo_result, true); return $userinfo_arr; }
function url2arr($url, $json) { if (C('psnvs') != 1) { $json = https_request($url); } $arr = json_decode($json, true); if ($arr['code'] != 'A00000') { logger('#', 'log/log_' . date('Y-m-d', time()) . '.txt'); logger('url: ' . $url, 'log/log_' . date('Y-m-d', time()) . '.txt'); logger('json: ' . $json, 'log/log_' . date('Y-m-d', time()) . '.txt'); } $arr['url'] = $url; return $arr; }
function getUserInfo($code) { $appid = "wx112a5b680de6941e"; $appsecret = "bc85e6bec70db896784884ec28151598"; //获取access token和openid https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code $new_access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code"; $new_access_token_json = https_request($new_access_token_url); $new_access_token_array = json_decode($new_access_token_json, true); $new_access_token = $new_access_token_array['access_token']; //全局access token获得用户基本信息https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN $userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$new_access_token}&openid={$openid}&lang=zh_CN"; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; }
function getUserInfo($code) { $appid = "wx0fed524d0dbafd1e"; $appsecret = "b3fca70bef3775f844f3597bb09a2e9d"; // oauth2的方式获得openid $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code"; $access_token_json = https_request($access_token_url); $access_token_array = json_decode($access_token_json, true); $openid = $access_token_array['openid']; // 非oauth2的方式获得全局access token $new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $new_access_token_json = https_request($new_access_token_url); $new_access_token_array = json_decode($new_access_token_json, true); $new_access_token = $new_access_token_array['access_token']; // 全局access token获得用户基本信息 $userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$new_access_token}&openid={$openid}"; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; }
function getUserInfo($code) { $appid = "wxfa12bc19b4ac3d1d"; $appsecret = "d0a07fefb8d531eb8fa74dae9f6dafdf"; //oauth2的方式获得openid $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code"; $access_token_json = https_request($access_token_url); $access_token_array = json_decode($access_token_json, true); $openid = $access_token_array['openid']; //通过接口获得access_token $new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $new_access_token_json = https_request($new_access_token_url); $new_access_token_array = json_decode($new_access_token_json, true); $new_access_token = $new_access_token_array['access_token']; //全局access token获得用户基本信息 $userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$new_access_token}&openid={$openid}"; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; }
function getUserInfo($code, $appid, $appsecret) { // $appid = "wx08c69e5ad5cc1a5e"; // $appsecret = "95c2d97c3557a65b5f6f7e962b363256"; //oauth2的方式获得openid $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code"; $access_token_json = https_request($access_token_url); $access_token_array = json_decode($access_token_json, true); $openid = $access_token_array['openid']; //非oauth2的方式获得全局access token $new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $new_access_token_json = https_request($new_access_token_url); $new_access_token_array = json_decode($new_access_token_json, true); $new_access_token = $new_access_token_array['access_token']; //全局access token获得用户基本信息 $userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$new_access_token}&openid={$openid}"; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; }
function getUserInfo($code) { $appid = "wx6292681b13329528"; $appsecret = "3079cb22ad383ae7371d12aed1b2d0cc"; //oauth2的方式获得openid $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code"; $access_token_json = https_request($access_token_url); $access_token_array = json_decode($access_token_json, true); $openid = $access_token_array['openid']; //非oauth2的方式获得全局access token $new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}"; $new_access_token_json = https_request($new_access_token_url); $new_access_token_array = json_decode($new_access_token_json, true); $new_access_token = $new_access_token_array['access_token']; //全局access token获得用户基本信息 $userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$new_access_token}&openid={$openid}"; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; }
function getTicket($access_token, $tempewm) { $data = json_decode(file_get_contents("jsapi_ticket.json")); if ($data->expire_time < time()) { // 如果是企业号用以下URL获取access_token // $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret"; $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token; $res = json_decode(https_request($url, $tempewm)); $jsapi_ticket = $res->ticket; if ($jsapi_ticket) { $data->expire_time = time() + 7000; $data->jsapi_ticket = $jsapi_ticket; $fp = fopen("jsapi_ticket.json", "w"); fwrite($fp, json_encode($data)); fclose($fp); } } else { $jsapi_ticket = $data->jsapi_ticket; } return $jsapi_ticket; }
function getJsApiTicket($accessToken) { // jsapi_ticket 应该全局存储与更新,以下代码以写入到文件中做示例 $data = json_decode(file_get_contents("jsapi_ticket.json")); if ($data->expire_time < time()) { // 如果是企业号用以下 URL 获取 ticket // $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken"; $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=" . $accessToken; $res = json_decode(https_request($url)); $ticket = $res->ticket; if ($ticket) { $data->expire_time = time() + 7000; $data->jsapi_ticket = $ticket; $fp = fopen("jsapi_ticket.json", "w"); fwrite($fp, json_encode($data)); fclose($fp); } } else { $ticket = $data->jsapi_ticket; } return $ticket; }
{ "type":"view", "name":"联系方式", "url":"http://www.toptophr.com/company/index.php?id=' . $_GET['uid'] . '&tp=connection&style=wap" }, { "type":"view", "name":"地理位置", "url":"http://www.toptophr.com/company/index.php?id=' . $_GET['uid'] . '&tp=position&style=wap" }] }] }'; $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token; $result = https_request($url, $jsonmenu); var_dump($result); function https_request($url, $data = null) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output;
require_once '../utils/Access_Token.class.php'; //$access_tokenApiObj = new Access_TokenApi(); //$access_token = $access_tokenApiObj->getAccess_Token(); $access_token = 'L43i6Tzh7k32FhT915yIOKcDipQODRiqubUByIh0asFTnCzy0YYzb5QJbsghECWBCtpi56bxwHaSqHS0BDBwAsSuDAGXEbhxxCqLSvrzU3g'; $openid = "oGer5jnhIvxmzFKZEtGnrv_yzHBc"; $data = '{ "touser":"******", "msgtype":"text", "text": { "content":"Hello World" } }'; $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $access_token; $result = https_request($url, $data); var_dump($result); function https_request($url, $data) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); if (curl_errno($curl)) { return 'Errno' . curl_error($curl); } curl_close($curl);
/** * 获取订单信息 * @param string $value [description] * @return [type] [description] */ public function getOrderInfo($trans_no, $type = 'normal') { $this->getMD5SIGN($trans_no); $data = $this->getField($trans_no); $result = https_request($this->orderInfo_url, $data); if (empty($result)) { return array('status' => '0'); } $ckResult = explode('|', $result); $oData = array('MemberID' => $ckResult[0], 'TerminalID' => $ckResult[1], 'TransID' => $ckResult[2], 'CheckResult' => $ckResult[3], 'succMoney' => $ckResult[4], 'SuccTime' => $ckResult[5], 'Md5Sign' => $ckResult[6]); $ck = $this->ckMD5SIGN($oData); if ($ck) { if ($type == 'normal') { return array('status' => '1', 'TransID' => $oData['TransID'], 'succMoney' => $oData['succMoney'] / 100, 'SuccTime' => date('Y-m-d H:i:s', strtotime($oData['SuccTime'])), 'CheckResult' => $oData['CheckResult']); } elseif ($type == 'all') { return $oData; } } else { return array('status' => '0'); } }
function getUserInfo($code) { $appid = "wxfb9fe4614872cea1"; $appsecret = "e61c7b972bceb87145ab150d70061c74"; //oauth2的方式获得openid $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $appsecret . "&code=" . $code . "&grant_type=authorization_code"; $access_token_json = https_request($access_token_url); $access_token_array = json_decode($access_token_json, true); $openid = $access_token_array['openid']; $access_token = $access_token_array['access_token']; /* //非oauth2的方式获得全局access token $new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret; $new_access_token_json = https_request($new_access_token_url); $new_access_token_array = json_decode($new_access_token_json, true); $new_access_token = $new_access_token_array['access_token']; //全局access token获得用户基本信息 $userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$new_access_token."&openid=".$openid; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; */ //oauth2获得用户基本信息 $userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token . "&openid=" . $openid; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); return $userinfo_array; }
function send_template_message($data) { $access_token = get_access_token(); $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token; $result = https_request($url, $data); return json_decode($result, true); }
require_once libfile('function/member'); $result = userlogin($_GET['username'], $_GET['password']); if (empty($result['status'])) { showmessage(lang('plugin/aljwsq', 'bind4')); } if (empty($openid)) { showmessage(lang('plugin/aljwsq', 'bind5')); } $config = $_G['cache']['plugin']['aljwsq']; if ($config['appid'] && $config['appsecret']) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $config['appid'] . "&secret=" . $config['appsecret']; $result = https_request($url); $jsoninfo = json_decode($result, true); $access_token = $jsoninfo["access_token"]; $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $_GET['openid'] . "&lang=zh_CN"; $wuser = https_request($url); $wuser = json_decode($wuser, true); } if ($openid) { if (!$user && $openid) { C::t('#aljwsq#aljwsq_user')->insert(array('nickname' => u2g($wuser['nickname']), 'username' => $_GET['username'], 'openid' => $openid, 'latitude' => $_GET['latitude'], 'longitude' => $_GET['longitude'], 'bindtime' => TIMESTAMP, 'sex' => $wuser['sex'], 'city' => u2g($wuser['city']), 'country' => u2g($wuser['country']), 'province' => u2g($wuser['province']), 'language' => $wuser['language'], 'headimgurl' => $wuser['headimgurl'], 'subscribe_time' => TIMESTAMP)); } else { C::t('#aljwsq#aljwsq_user')->update($openid, array('nickname' => u2g($wuser['nickname']), 'username' => $_GET['username'], 'latitude' => $_GET['latitude'], 'longitude' => $_GET['longitude'], 'bindtime' => TIMESTAMP, 'sex' => $wuser['sex'], 'city' => u2g($wuser['city']), 'country' => u2g($wuser['country']), 'province' => u2g($wuser['province']), 'language' => $wuser['language'], 'headimgurl' => $wuser['headimgurl'])); } } showmessage(lang('plugin/aljwsq', 'bind6'), 'forum.php?openid=' . $openid); } else { $binduser = DB::fetch_first('SELECT * FROM %t WHERE openid=%s', array('aljwsq_user', $openid)); if ($binduser && $binduser['username']) { echo '<script>alert("' . $config['albindtips'] . '");location.href="forum.php?mobile=2&openid=' . $openid . '"</script>'; exit;
function getDeviceList($MWID) { $deviceListUrl = "http://www.cloudsensing.cn:9071/WIFPa/MWAttribute/" . "{$MWID}" . ".xml"; $deviceList = https_request($deviceListUrl); return $deviceList; }
$nonce = random(5); $token = $curkeyword['description']; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if (strpos($curkeyword['url'], '?') === false) { $curkeyword['url'] = $curkeyword['url'] . '?'; } $return = https_request($curkeyword['url'] . "&token={$curkeyword['description']}&signature={$tmpStr}×tamp={$timestamp}&nonce={$nonce}", $postStr); } else { foreach ($keywords as $keyword) { $timestamp = TIMESTAMP; $nonce = random(5); $token = $keyword['description']; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if (strpos($keyword['url'], '?') === false) { $keyword['url'] = $keyword['url'] . '?'; } //logResult($keyword['url']."&token={$keyword['description']}&signature={$tmpStr}×tamp={$timestamp}&nonce={$nonce}"."\r"); $return = https_request($keyword['url'] . "&token={$keyword['description']}&signature={$tmpStr}×tamp={$timestamp}&nonce={$nonce}", $this->u2g($postStr)); //logResult($return); //logResult($postStr); if ($return) { break; } } }
/** * 发送客服消息 */ public function send_message_by_openid($openid, $msg, $type = 'text') { $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$this->access_token}"; switch ($type) { case 'text': $data = '{ "touser":"******", "msgtype":"' . $type . '", "text":{"content":"' . $msg . '"} }'; break; case 'image': $data = '{ "touser":"******", "msgtype":"' . $type . '", "image":{"media_id":"' . $msg . '"} }'; break; case 'news': $data = '{ "touser":"******", "msgtype":"' . $type . '", "news":{"articles": [' . $msg . ']} }'; break; } $res = https_request($url, $data); return json_decode($res, true); }
header('Content-type: text/html; charset=utf-8'); $appid = 'wxd3da8189b5ec1ba7'; $appsecret = 'b71109103ce5d7fd079636d23444081d'; if (isset($_GET['code'])) { $code = $_GET['code']; $token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code"; $res = https_request($token_url); $res_array = json_decode($res, true); $access_token = $res_array['access_token']; $openid = $res_array['openid']; $refresh_token = $res_array['refresh_token']; setcookie("draw_openid", $openid); setcookie("refresh_token", $refresh_token); //获取用户信息并存入cookie $info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$access_token}&openid={$openid}"; $res_info = https_request($info_url); $info_array = json_decode($res_info, true); $nickname = $info_array['nickname']; setcookie("draw_nickname", $nickname); $headimgurl = $info_array['headimgurl']; setcookie("draw_logo", $headimgurl); //echo $_COOKIE["draw_nickname"]; //echo $_COOKIE["draw_logo"]; //echo $_COOKIE["draw_openid"]; echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"; echo "<script language='javascript' type='text/javascript'>"; echo "window.location.href='index.php' ; "; echo "</script>"; } else { echo "NO CODE"; }
public function SendVideo($openId, $videoArray) { // thumb_media_id : not option! $access_token = get_Access_Token(); $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $access_token; $data = '{ "touser":"******", "msgtype":"video", "video": { "title":"' . $videoArray['Title'] . '", "description":"' . $videoArray['Description'] . '", "media_id":"' . $videoArray['Media_id'] . '" } }'; $ret = https_request($url, $data); var_dump($ret); sae_debug($ret); }
} elseif ($_SESSION['username'] && $_SESSION['utype'] && $_COOKIE['QS']['username'] && $_COOKIE['QS']['password']) { header("Location:" . get_member_url($_SESSION['utype'])); } elseif ($act == 'login') { /** * 微信扫描登录start */ if (intval($_CFG['weixin_apiopen']) == 1) { $access_token = get_access_token(); $scene_id = rand(1, 10000000); $_SESSION['scene_id'] = $scene_id; $dir = QISHI_ROOT_PATH . 'data/weixin/' . $scene_id % 10; make_dir($dir); $fp = @fopen($dir . '/' . $scene_id . '.txt', 'wb+'); $post_data = '{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": ' . $scene_id . '}}}'; $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token; $result = https_request($url, $post_data); $result_arr = json_decode($result, true); $ticket = urlencode($result_arr["ticket"]); $html = '<img width="120" height="120" src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . $ticket . '">'; $smarty->assign('qrcode_img', $html); } /** * 微信扫描登录end */ $smarty->assign('title', '会员登录 - ' . $_CFG['site_name']); $smarty->assign('error', $_GET['error']); $smarty->assign('url', $_GET['url']); $captcha = get_cache('captcha'); $smarty->assign('verify_userlogin', $captcha['verify_userlogin']); $smarty->display($mypage['tpl']); }
private function receiveText($obj) { $keyword = trim($obj->Content); if (is_numeric($keyword) && $keyword >= 100 && $keyword < 200) { /* $callUri ="http://duplicall.eicp.net:8088/rs/smarttap/calls/info?maxResults=10&sortField=startTime&sortOrder=DESC&targetId=".$keyword; $credentials = "admin:admin"; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$SWXurl); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $credentials); curl_setopt($ch,CURLOPT_HTTPHEADER,array("Accept: application/json")); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); $output = curl_exec($ch); curl_close($ch); */ //$content ="您发送的是数字文本:" . $keyword; $smcValue = SaeMemCache_get($obj->FromUserName . "key"); $content = $smcValue; $result = $this->transmitText($obj, $content); //if (SaeMemCache_get($obj->FromUserName."key",$obj->FromUserName."Recording"); } else { switch (strtolower($keyword)) { case "id": $access_token = get_Access_Token(); $result = $this->transmitText($obj, "Access_Token: " . $access_token); break; case "61": $CC = new CCInterface(); $CC->SendMsg($obj->FromUserName, "【DC测试】六一节快乐 "); break; case "users": $SWXurl = "http://duplicall.eicp.net:8088/rs/smarttap/users/info"; $credentials = "admin:admin"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $SWXurl); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $credentials); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $retArray = json_decode($output, true); $userArray = $retArray['usersInfo']; usort($userArray, function ($a, $b) { if ($a["id"] == $b["id"]) { return 0; } return $a["id"] < $b["id"] ? -1 : 1; }); foreach ($userArray as $user) { //$content .= $user["uri"]."|".$user["id"]."|".$user["displayName"]."|".$user["disabled"]."|".$user["firstName"]."|".$user["lastName"]."|".$user["emailAddress"]."|".$user["alias"]."|".$user["loginId"]."\n"; $content .= $user["id"] . ":" . $user["firstName"] . "," . $user["lastName"] . "\n"; } $result = $this->transmitText($obj, $content); break; case "code": $appid = APPID; $redirect_uri = REDIRECT_URI; $auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $appid . "&redirect_uri=" . $redirect_uri . "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect"; $content = 'DupliCALL UCenter Oauth2.0 <a href="' . $auth_url . '">点击这里进行授权</a>'; $result = $this->transmitText($obj, $content); break; case "auth": $appid = APPID; $appsecret = APPSECRET; $mysql = new SaeMysql(); $sql = "SELECT * FROM `gParameters` WHERE `name` ='gAuthCode'"; $data = $mysql->getLine($sql); $authCode = $data["Value"]; $mysql->closeDb(); $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $appsecret . "&code=" . $authCode . "&grant_type=authorization_code"; $result1 = https_request($url); $jsoninfo = json_decode($result1, true); $authAccessToken = $jsoninfo["access_token"]; $authRefreshToken = $jsoninfo["refresh_token"]; $authOpenId = $jsoninfo["openid"]; $authScope = $jsoninfo["scope"]; $userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $authAccessToken . "&openid=" . $authOpenId; $userinfo_json = https_request($userinfo_url); $userinfo_array = json_decode($userinfo_json, true); $userOpenid = $userinfo_array["openid"]; $userNickname = $userinfo_array["nickname"]; if ($userinfo_array["sex"] == 1) { $userSex = "先生"; } else { $userSex = "女士"; } $userLanguage = $userinfo_array["language"]; $userCity = $userinfo_array["city"]; $userProvince = $userinfo_array["province"]; $userCountry = $userinfo_array["country"]; $userImg = $userinfo_array["headimgurl"]; $content1 = "OpenId : " . $userOpenid . "\n Nickname : " . $userNickname . "\n Sex : " . $userSex . "\n Language : " . $userLanguage . "\n Location : " . $userCountry . "/" . $userProvince . "/" . $userCity . "\n"; //$content .= '<img src="'. $userImg.'" >'; $content[] = array("Title" => $userNickname, "Description" => $content1, "PicUrl" => $userImg); $result = $this->transmitNews($obj, $content); break; case "文本": case "text": $content = "欢迎参加DupliCALL公众号测试|Welcome to join the test of DupliCALL's Public WX Account"; $result = $this->transmitText($obj, $content); break; case "音乐": case "music": $content = array("Title" => "最美", "Description" => "歌手:羽泉", "MusicUrl" => "http://duplicall.eicp.net:3476/0111.mp3", "HQMusicUrl" => "http://duplicall.eicp.net:3476/0111.mp3"); $result = $this->transmitMusic($obj, $content); break; case "图文": case "单图文": $content = array(); $content[] = array("Title" => "DupliCALL 公司介绍", "Description" => "Full-Time Lync Recorder", "PicUrl" => "http://www.ai-logix.com.cn/eng/images/logos/smartworks_box_logo-s.jpg", "Url" => "http://www.ai-logix.com.cn/chs/products.htm"); $result = $this->transmitNews($obj, $content); break; case "多图文": $content = array(); $content[] = array("Title" => "DupliCALL技术支持", "Description" => "在线技术支持", "PicUrl" => "http://www.ai-logix.com.cn/chs/images/support_box.jpg", "Url" => "http://www.ai-logix.com.cn/chs/support.htm"); $content[] = array("Title" => "产品资料下载", "Description" => "", "PicUrl" => "http://www.ai-logix.com.cn/chs/images/companypage_banner_large.jpg", "Url" => "http://www.ai-logix.com.cn/chs/support-down-smartworks.htm"); $content[] = array("Title" => "Skype在线通话技术支持", "Description" => "使用Skype在线互联网电话软件", "PicUrl" => "http://www.ai-logix.com.cn/chs/images/support.jpg", "Url" => "http://www.ai-logix.com.cn/chs/support-skype.htm"); $content[] = array("Title" => "FAQ技术问答", "Description" => "使用Skype在线互联网电话软件", "PicUrl" => "http://www.ai-logix.com.cn/chs/images/solutions_box.jpg", "Url" => "http://www.ai-logix.com.cn/chs/support-down-faq.htm"); $result = $this->transmitNews($obj, $content); break; default: $content = "您发送的是文本消息,内容如下:" . $keyword; $result = $this->transmitText($obj, $content); } } return $result; }
$html .= "<div class='con'><div class='f-left'><img src='{$_CFG['site_template']}images/wx_showmsg.jpg'></div><div class='f-right tex'>微信登录更简单安全,且可防止木马、键盘录制窃取密码,确定要关闭微信安全登录吗?</div><div class='clear'></div></div>"; $html .= "<div class='sclosePd'><a class='sclose f-left' href='javascript:;' id='bind_wx_true' uid='" . $user['uid'] . "'>确认</a><a class='sclose f-left sclosem' href='javascript:;'>取消</a></div>"; $html .= "</div>"; } } exit($html); } elseif ($act == 'waiting_weixin_scan') { $event_key = $_SESSION['scene_id']; $openid = ""; if (file_exists(QISHI_ROOT_PATH . "data/weixin/" . $event_key % 10 . '/' . $event_key . ".txt")) { $openid = file_get_contents(QISHI_ROOT_PATH . "data/weixin/" . $event_key % 10 . '/' . $event_key . ".txt"); } if ($openid) { $access_token = get_access_token(); $w_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $openid . "&lang=zh_CN"; $w_result = https_request($w_url); $w_userinfo = json_decode($w_result, true); $w_userinfo = array_map('utf8_to_gbk', $w_userinfo); global $db; $result = $db->query("update " . table('members') . " set weixin_openid='" . $openid . "',weixin_nick='" . $w_userinfo['nickname'] . "' where uid=" . $_SESSION['uid'] . " and weixin_openid IS NULL"); if ($result) { // 绑定微信 获得积分 $rule = get_cache('points_rule'); if ($rule['company_wx_points']['value'] > 0) { $info = $db->getone("SELECT uid FROM " . table('members_handsel') . " WHERE uid ='{$_SESSION['uid']}' AND htype='company_wx_points' LIMIT 1"); if (empty($info)) { $time = time(); $db->query("INSERT INTO " . table('members_handsel') . " (uid,htype,addtime) VALUES ('{$_SESSION['uid']}', 'company_wx_points','{$time}')"); require_once QISHI_ROOT_PATH . 'include/fun_comapny.php'; report_deal($_SESSION['uid'], $rule['company_wx_points']['type'], $rule['company_wx_points']['value']); $user_points = get_user_points($_SESSION['uid']);
/** * @车源列表 * http://api.che300.com/service/getCarList * @param zone unsigned int 城市标识,可以通过车300城市数据接口拿回车300所支持的所有城市标识,也可以申请合作成功之后提供网站自己的城市信息进行两者之间的映射。 * @param page unsigned int 车源列表页码,也就是需要拿第几页车源,每页最多会有20条车源,如果不足20条会全部返回。如果不给的话,默认为1。 * @param keyword string 搜索关键字,根据改关键字进行搜索提供车源,如:宝马X1。 * @param carBrand unsigned int 品牌ID,可以通过车300的品牌数据接口拿回所有的品牌相关信息。 * @param carSeries unsigned int 车系ID,可以通过车300的车系数据接口拿回指定品牌下的所有车系相关信息。 * @param carModel unsigned int 车型ID,可以通过车300的车型数据接口拿回指定车系下的所有车型相关信息。 * @param carYear string 车龄,既可以指定一个区间(如:3-5),也可以指定一个具体的上牌年份(如:2009)。 * @param carMile string 车辆里程,既可以指定一个区间(如:3-5),也可以指定一个具体的公里数(如:10),该参数表达的意思是大于等于多少万公里。 * @param carPrice string 车辆价格,既可以指定一个区间(如:3-5),也可以指定一个具体的数目(如:10),该参数表达的意思是大于等于多少万元。 * @param sellerType string 卖家类型,1表示个人,2表示商家,不指定的话返回结果就是个人和商家混合车源。 * @param vprSort string 性价比排序,指定返回的车源按照性价比排序。可以取值asc和desc,其中asc表示升序,desc表示降序。该排序和其它排序方式一样,只会有一种生效,在调用接口的时候只需要指定一种排序即可。如果不指定的话,默认会是下面的发布时间排序。 * @param priceSort string 价格排序,指定返回的车源按照价格排序。可以取值asc和desc,其中asc表示升序,desc表示降序。该排序和其它排序方式一样,只会有一种生效,在调用接口的时候只需要指定一种排序即可。如果不指定的话,默认会是下面的发布时间排序。 * @param registerDateSort string 上牌时间排序,指定返回的车源按照上牌时间排序。可以取值asc和desc,其中asc表示升序,desc表示降序。该排序和其它排序方式一样,只会有一种生效,在调用接口的时候只需要指定一种排序即可。如果不指定的话,默认会是下面的发布时间排序。 * @param mileAgeSort string 车辆里程排序,指定返回的车源按照车辆里程排序。可以取值asc和desc,其中asc表示升序,desc表示降序。该排序和其它排序方式一样,只会有一种生效,在调用接口的时候只需要指定一种排序即可。如果不指定的话,默认会是下面的发布时间排序。 * @param postDateSort string 发布时间排序,指定返回的车源按照发布时间排序。可以取值asc和desc,其中asc表示升序,desc表示降序。该排序和其它排序方式一样,只会有一种生效,在调用接口的时候只需要指定一种排序即可。如果不指定的话,默认会是下面的发布时间排序。 * @return array * @example:$data=array('zone'=>'','page'=>'','keyword'=>'','carBrand'=>'','carSeries'=>'','carModel'=>'', 'carYear'=>'','carMile'=>'', 'carPrice'=>'','sellerType'=>'', 'vprSort'=>'', 'priceSort'=>'', 'registerDateSort'=>'','mileAgeSort'=>'','postDateSort'=>''); */ public function getCarList($data) { $this->param['zone'] = $data['zone']; $this->param['page'] = $data['page']; $this->param['keyword'] = $data['keyword']; $this->param['carBrand'] = $data['carBrand']; $this->param['carSeries'] = $data['carSeries']; $this->param['carModel'] = $data['carModel']; $this->param['carYear'] = $data['carYear']; $this->param['carMile'] = $data['carMile']; $this->param['carPrice'] = $data['carPrice']; $this->param['sellerType'] = $data['sellerType']; $this->param['vprSort'] = $data['vprSort']; $this->param['priceSort'] = $data['priceSort']; $this->param['registerDateSort'] = $data['registerDateSort']; $this->param['mileAgeSort'] = $data['mileAgeSort']; $this->param['postDateSort'] = $data['postDateSort']; $this->param = array_filter($this->param); $paramStr = createLinkstringUrlencode($this->param); $url = $this->apiUrl . 'getCarList?' . $paramStr; $result = https_request($url); if (empty($result)) { $result = array('status' => false, 'msg' => '无法获取che300数据'); } else { $result = json_decode($result, true); } return $result; }