/** * 获得数据列表 */ public function doDefault(ZOL_Request $input, ZOL_Response $output) { //获得所有会员类型 $output->memberCate = Helper_Member::getMemberCatePairs(); //获得所有的员工 $output->staffArr = Helper_Staff::getStaffPairs(); //获得所有配置 $output->sysOptions = Helper_Option::getAllOptions(); $output->scoreRatio = !empty($output->sysOptions["ScoreRatio"]) ? $output->sysOptions["ScoreRatio"]["value"] : 0; //获得商品的所有分类 $output->productCateArr = Helper_Product::getProductCatePairs(); $output->productCateJson = api_json_encode($output->productCateArr); $output->setTemplate('Checkout'); }
public function doGetMemberOtherPro(ZOL_Request $input, ZOL_Response $output) { $phone = $input->get('phone'); $phonecard = $input->get('phonecard'); if ((!$phone || !is_numeric($phone)) && (!$phonecard || !is_numeric($phonecard))) { echo "{}"; exit; } $list = Helper_Member::getOtherPros(array('phone' => $phone, 'phoneOrCardno' => $phonecard)); if ($list) { echo api_json_encode($list); } else { echo "{}"; } exit; }
private function doPost(ZOL_Request $input, ZOL_Response $output) { $db = Db_Andyou::instance(); $res = $output->data; if ($res) { $data = array(); foreach ($res as $re) { $re["site"] = $output->sysName; $re["objId"] = $re["id"]; unset($re["id"]); unset($re['rowTm']); $data[] = $re; } $jsonstr = base64_encode(api_json_encode($data)); echo $jsonstr . "<hr/>"; $token = md5($output->url . "AAFDFDF&RE3"); $rtn = ZOL_Http::curlPost(array('url' => $output->yunUrl . "?" . $output->url . "&token={$token}", 'postdata' => "table={$output->table}&data={$jsonstr}", 'timeout' => 3)); return $rtn; } return false; }
/** * 根据电话号码获得产品信息 */ public function doGetProductByCode(ZOL_Request $input, ZOL_Response $output) { $code = $input->get('code'); $fromScore = (int) $input->get('fromScore'); if (!$code) { echo "{}"; exit; } $proList = Helper_Product::getProductList(array('code' => $code, 'num' => 30, 'canByScore' => $fromScore)); if ($proList) { //完善产品的分类信息 $catePairs = Helper_Product::getProductCatePairs(); foreach ($proList as $k => $p) { $proList[$k]['cateName'] = $catePairs[$p["cateId"]]; } $data = array('num' => count($proList), 'data' => $proList); echo api_json_encode($data); } else { echo "{}"; } exit; }
/** * 自动表单验证 * @access protected * @param array $data 创建数据和类型 * @return boolean */ public function autoValidation($_validate, $jsonFlag = false) { if ($_validate && is_array($_validate)) { foreach ($_validate as $key => $val) { // array(field,rule,message,condition,type,when,params) $returnArr = array('status' => true, 'message' => ''); $val[3] = isset($val[3]) ? $val[3] : 'regex'; if (!isset($val[2]) || empty($val[2]) || $val[2] == 'post') { $returnArr['status'] = self::check(self::post($val[0]), $val[1], $val[3]); } else { $returnArr['status'] = self::check(self::get($val[0]), $val[1], $val[3]); } if (!$returnArr['status']) { if ($jsonFlag) { echo api_json_encode(array('state' => 0, 'msg' => isset($val[4]) ? $val[4] : '[' . $val[0] . ']数据提交错误,请重试!')); exit; } else { $returnArr['message'] = isset($val[4]) ? $val[4] : '[' . $val[0] . ']数据提交错误,请重试!<br /><a href="javascript:history.go(-1);">返回上一页</a>'; Helper_Func_Front::showMsg(array('message' => $returnArr['message'], 'level' => 2)); } } } } }
/** * 检验消息的真实性,并且获取解密后的明文. * <ol> * <li>利用收到的密文生成安全签名,进行签名验证</li> * <li>若验证通过,则提取xml中的加密消息</li> * <li>对消息进行解密</li> * </ol> * * @param $msgSignature string 签名串,对应URL参数的msg_signature * @param $timestamp string 时间戳 对应URL参数的timestamp * @param $nonce string 随机串,对应URL参数的nonce * @param $postData string 密文,对应POST请求的数据 * @param &$msg string 解密后的原文,当return返回0时有效 * * @return int 成功0,失败返回对应的错误码 */ public function DecryptMsg($sMsgSignature, $sTimeStamp = null, $sNonce, $sPostData, &$data) { if (strlen($this->m_sEncodingAesKey) != 43) { return ErrorCode::$IllegalAesKey; } $pc = new Prpcrypt($this->m_sEncodingAesKey); //提取密文 $xmlparse = new XMLParse(); $array = $xmlparse->extract($sPostData); $ret = $array[0]; if ($ret != 0) { return $ret; } if ($sTimeStamp == null) { $sTimeStamp = time(); } $encrypt = $array[1]; $touser_name = $array[2]; //验证安全签名 $sha1 = new SHA1(); $array = $sha1->getSHA1($this->m_sToken, $sTimeStamp, $sNonce, $encrypt); $ret = $array[0]; if ($ret != 0) { return $ret; } $signature = $array[1]; if ($signature != $sMsgSignature) { return ErrorCode::$ValidateSignatureError; } $result = $pc->decrypt($encrypt, $this->m_sCorpid); if ($result[0] != 0) { return $result[0]; } $sMsg = $result[1]; $data = array(); $xml = simplexml_load_string($sMsg, 'SimpleXMLElement', LIBXML_NOCDATA); $data = api_json_decode(api_json_encode($xml), TRUE); // if($xml){ // foreach ($xml as $key => $value) { // $data[$key] = mb_convert_encoding(strval($value),"GBK","UTF-8");; // } // } return ErrorCode::$OK; }
private function doPost(ZOL_Request $input, ZOL_Response $output) { $db = Db_Andyou::instance(); $res = $output->data; if ($res) { $data = array(); foreach ($res as $re) { $re["site"] = $output->sysName; //获得会员的信息 if (in_array($output->table, array("log_scorechange", "log_cardchange"))) { $minfo = Helper_Member::getMemberInfo(array("id" => $re["memberId"])); $re["phone"] = $minfo["phone"]; } if (in_array($output->table, array("bills"))) { if (empty($re["phone"])) { $minfo = Helper_Member::getMemberInfo(array("id" => $re["memberId"])); $re["phone"] = $minfo["phone"]; $db->query("update {$output->table} set phone = '{$minfo["phone"]}' where memberId = {$re["memberId"]}"); } } $data[] = $re; } $jsonstr = base64_encode(api_json_encode($data)); echo $jsonstr . "<hr/>"; $token = md5($output->url . "AAFDFDF&RE3"); $rtn = ZOL_Http::curlPost(array('url' => $output->yunUrl . "?" . $output->url . "&token={$token}", 'postdata' => "table={$output->table}&data={$jsonstr}", 'timeout' => 3)); return $rtn; } return false; }
/** * 发送模板信息接口 * @param type $paramArr * @return type */ public static function sendTemplateMessage($paramArr) { $options = array('appId' => '', 'appSecret' => '', 'dataArr' => ''); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); if (empty($appId) || empty($appSecret) || empty($dataArr)) { return false; } #获得access_token $tokenDataArr = self::getAccessToken(array('appId' => $appId, 'appSecret' => $appSecret)); #获得 access_token $accessToken = ""; if (!empty($tokenDataArr['state'])) { $accessToken = $tokenDataArr['data']; } else { return false; } $jsonStr = ""; $jsonStr = API_Http::curlPost(array('url' => 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $accessToken, 'postdata' => !empty($dataArr) ? api_json_encode($dataArr) : '')); $jsonArr = array(); $jsonArr = api_json_decode($jsonStr); if (!empty($jsonArr['errmsg'])) { if ($jsonArr['errmsg'] == 'ok' && $jsonArr['errcode'] == '0') { return true; } } else { return false; } }
} $docArr[] = $v['document_id']; $i++; } // recordArticle($docArr); # 数据条数 $finalNum = count($fResult); $fResult[0]['dataSource'] = 'zol'; $fResult[0]['dataPageMax'] = $finalNum / 12; $fResult[0]['dataDebug'] = $docArr[0]; $msg = '数据不足' . $needNum . '条'; if ($finalNum < $needNum) { //mail('*****@*****.**','【ZOL首页"猜你喜欢"数据故障】',date('Y-m-d H:i:s ==> ').$msg."\r\n".__FILE__.__LINE__); #toLog(array($ip_key=>count($fResult),)); } $fResult = api_json_encode($fResult); $j = json_encode($fResult); echo $callback ? $callback . '(' . $j . ')' : $j; if ($debug) { $end_time = microtime(true); $exec_time = $end_time - $start_time; $needTime = round($exec_time, 6); echo '<h2 style="color:red;font-weight:bold;">页面执行了' . $needTime . '秒</h2>'; storage_tmp_data($needTime); } return ''; exit(''); /*********************************以下是一些需要用到的函数**********************************************************/ # 根据一串doc_id获取需要的数据 function get_data_by_docid($idArr, $fields = 'document_id,title,class_id') {
/** * 获得最新的数据 */ public function doGetNew(ZOL_Request $input, ZOL_Response $output) { $token = $input->get("token"); $tm = (int) $input->get("tm"); //token的验证 // if ($token != md5("c=Rsync_Member&a=GetNew&tm={$tm}" . "AAFDFDF&RE3")) { echo "001"; exit; } $db = Db_AndyouYun::instance(); $sql = "select name,phone,cardno,cateId,byear,bmonth,bday,addTm,remark,introducer,introducerId,allsum,upTm,score,balance,site,siteObjId " . " from member where (addTm > {$tm} or upTm > {$tm})"; $data = $db->getAll($sql); $jsonstr = api_json_encode($data); echo $jsonstr; exit; }
/** * 接收表单 生成订单,并显示支付二维码 * @param ZOL_Request $input * @param ZOL_Response $output */ public function doDefault(ZOL_Request $input, ZOL_Response $output) { #队列异步回调的url的域名部分 $baseUrl = 'http://reward.suhy.test.zol.com.cn'; #支付的baseurl $payBaseUrl = 'http://10.19.38.115:8990'; # 报错模板的html $errorHtml = $output->fetchCol('ShowPayError'); # token验证 if (!Helper_Reward_RewardFunc::verityRewardToken($input, $output)) { # 显示报错模板 $errorArr = array('flag' => 'error', 'msg' => '请不要重复提交!', 'errorCode' => 8001, 'toLog' => 1, 'showHtml' => $errorHtml); Helper_Reward_RewardFunc::ajaxExit($errorArr); } else { # 重置该用户的token //验证的时候就已经重置了 } if (!$output->url || !$output->money || !$output->articleId) { # 显示报错模板 Helper_Reward_RewardFunc::ajaxExit(array('flag' => 'error', 'msg' => '金额不合法或缺少文章id', 'showHtml' => $errorHtml)); } # 文章页的话的收款人是文章作者,其他业务的不同 if ($output->ext1 <= 0) { $output->payee = Helper_Reward_RewardFunc::getArticleAuthor(array('articleId' => $output->articleId)); } else { } $output->orderNo = Helper_Reward_RewardFunc::getOrderNumber(); $output->userIp = ZOL_Api::run("Service.Area.getClientIp", array()); /* # 订单入库 $id = Helper_Reward_RewardModel::insertData(array( 'order_name' => $output->orderName, 'order_number' => $output->orderNo, 'article_id' => $output->articleId, 'url' => $output->url, 'insert_date' => SYSTEM_DATE, 'pay_time' => NULL, 'custmer' => $output->userId, 'money' => $output->money, 'message' => $output->message, 'payment' => $output->payment, 'order_status' => 0, 'payee' => $output->payee,# 'service_type' => 1,# 1资讯文章打赏 2.论坛(暂不支持) #'debug' => 1, ));*/ # 消息体/数据体 $putQueueBody = array('order_name' => $output->orderName, 'order_number' => $output->orderNo, 'article_id' => $output->articleId, 'ext1' => $output->ext1, 'ext2' => $output->ext2, 'url' => $output->url, 'insert_date' => SYSTEM_DATE, 'pay_time' => NULL, 'custmer' => $output->userId, 'money' => $output->money, 'message' => $output->message, 'payment' => $output->payment, 'order_status' => 0, 'payee' => $output->payee, 'service_type' => $output->serviceType); $putQueueData = array('queue' => 'ArticleReward', 'producer' => iconv('GB2312', 'UTF-8//IGNORE', '媒体平台-打赏'), 'consumerUrls' => 'http://reward.suhy.test.zol.com.cn/?c=Queue_DealQueue&a=DealQueueOrder', 'msgType' => 'json', 'charset' => 'utf-8', 'priority' => 0, 'persistent' => true, 'version' => '1.0', 'content' => iconv('GBK', 'UTF-8//IGNORE', $output->message), 'flag' => 1, 'id' => 123, 'body' => api_json_encode($putQueueBody)); #var_dump($putQueueData);exit(); # 将订单数据推入队列,进行异步插入数据库 $result = Libs_Reward_CurlRequest::curlPostMethod(array('url' => 'http://10.19.38.115:8990/queue/putmessage?queuename=ArticleReward&token=8951f7339caee44b23383cdded9a3d2b66', 'pull_data' => json_encode($putQueueData), 'data_type' => 'json')); $result = json_decode($result, true); # 如果800,则入队成功 if ($result['resultCode'] != 800) { Helper_Reward_RewardFunc::ajaxExit(array('flag' => 'error', 'errorCode' => 8002, 'queueErrorCode' => $result['resultCode'], 'msg' => '[8002]生成订单失败!,加入队列失败!', 'toLog' => 1, 'showHtml' => $errorHtml)); } # 此时已经是“分”作为单位 $moneyCents = $output->money; # 默认支付宝 $payType = 'alipay'; switch ($output->payment) { case 1: $payType = 'alipay'; break; case 2: $payType = 'wxpay'; break; } $notifyUrl = 'http://reward.suhy.test.zol.com.cn/?c=Queue_DealQueue&a=DealPayNotice&sign='; $callbackUrl = 'http://reward.suhy.test.zol.com.cn/?c=FormHtml&a=ShowPaySuccess'; # 处理支付事宜,给支付网关发送xml $xmlStr = Libs_Reward_SimpleXML::getXmlStr(array('root_node' => 'xml', 'data_array' => array('partnerId' => 101, 'userId' => $output->userId, 'orderId' => $output->orderNo, 'goodsDesc' => $output->message, 'payType' => $payType, 'goodsName' => $output->orderName, 'goodsUrl' => $output->url, 'fee' => $moneyCents, 'clientType' => 'PC', 'clientIp' => $output->userIp, 'attach' => '', 'signType' => 'md5', 'notifyUrl' => $notifyUrl, 'callbackUrl' => $callbackUrl))); #var_dump($xmlStr);exit(); #$xmlStr = '<xml><partnerId>101</partnerId><orderId>2015122312123</orderId><goodsDesc>测试订单</goodsDesc><payType>WXPAY</payType><goodsName>龙芯一号</goodsName><goodsUrl>http://www.zol.com/detail/diy_host/ZXDN/25544595.html</goodsUrl><fee>6999</fee><clientType>PC</clientType><clientIp>10.16.38.115</clientIp><attach>附件</attach><signType>md5</signType></xml>'; #$xmlStr = '<xml><partnerId>101</partnerId><orderId>2015122312123</orderId><goodsDesc>打赏文章</goodsDesc><payType>WXPAY</payType><goodsName>龙芯一号</goodsName><goodsUrl>http://www.zol.com/detail/diy_host/ZXDN/25544595.html</goodsUrl><fee>69119</fee><clientType>PC</clientType><clientIp>10.16.38.115</clientIp><attach>附件</attach><signType>md5</signType></xml>'; #$xmlStrGBK = $xmlStr; $xmlStr = iconv('GBK', 'UTF-8//IGNORE', $xmlStr); $xmlStr = base64_encode($xmlStr); # Crypt3Des加密 $rep = new Libs_Reward_Crypt3Des('@!@!@'); $sign = md5($rep->encrypt($xmlStr)); #var_dump($xmlStr,$sign);exit(); /* # 请求ZOL支付网关 $data = Libs_Reward_CurlRequest::curlPostMethod(array( 'url' => 'http://10.19.37.162:8080/paygate/payment/scan/prepay?sign='.$sign, 'pull_data' => $xmlStr, 'data_type' =>'xml', )); if(!$data){ # 异常,记录日志 Helper_Reward_RewardFunc::ajaxExit(array( 'flag' => 'error', 'errorCode' => 8004, 'msg' => '[8004]xml捕获失败,请求支付网关的xml,返回异常!', 'toLog' => 1, 'showHtml' => $errorHtml, )); } # ZOL支付接口状态码 $payStatusCode = array( '800'=>'正常', '801'=>'XML报文为NULL', '802'=>'签名验证错误', '803'=>'XML解析失败', '805'=>'支付类型错误', '806'=>'没有找到接入方ID', ); # 解析xml $xml = new SimpleXMLElement($data); $xmlArr = array(); foreach($xml as $k=>$v){ $xmlArr[$k] = $v; } #var_dump($xmlArr);exit(); $statusCode = (array)$xml->resultCode; if($statusCode[0] != 800){ $errorMsg = isset($payStatusCode[$statusCode[0]]) ? $payStatusCode[$statusCode[0]] : ''; Helper_Reward_RewardFunc::ajaxExit(array( 'flag' => 'error', 'errorCode' => 8003, 'payErrorCode'=>$statusCode[0], 'msg' => '[8003]支付发生异常!请求支付网关后,返回的xml状态码异常!'.$errorMsg."$statusCode[0]", 'toLog' => 1, 'showHtml' => $errorHtml, )); } $src = $output->src = isset($xmlArr['payUrl']) ? $xmlArr['payUrl'] : ''; */ # 如果是支付宝,则进行跳转新页面 1表示支付宝 if ($output->payment == 1) { #$src = $output->src = 'http://10.19.38.115:8080'.$src; #header('Location:'.$src); } $targetStr = $output->payment == 1 ? '' : 'target="iframeQCode"'; # 方案2 Start 20160104 http://localhost/www/class_of_me/www/reward/test.php http://cashier.zol.com/paygate/pay?partnerId=101 $way2 = '<form id="form_zolpaygate" action="http://cashier.zol.com/paygate/pay?partnerId=101" method="post" ' . $targetStr . '> <input type="hidden" name="_data" value="' . $xmlStr . '"> <input type="hidden" name="sign" value="' . $sign . '"> <script type="text/javascript">document.forms["form_zolpaygate"].submit();</script> </form>'; $output->way2 = $way2; #echo $way2;return ''; # 方案2 End # 二维码的HTML $output->qCodeHtml = $qCodeHtml = Reward_Plugin_PayQCode::getPayHtml($input, $output); $output->setTemplate('RewardQCode'); return ''; }
public static function mutateMediabuy($paramArr) { $options = array('op' => '', 'id' => 0, 'name' => '', 'orderId' => self::$_orderId, 'price' => 0, 'paymentType' => '', 'dateArr' => array(), 'target' => '', 'placeIdArr' => array(), 'adspaceIdArr' => array(), 'status' => 0); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); //操作类型 $op = isset(self::$_operateArr[$op]) ? self::$_operateArr[$op] : 0; //计费方式 if ($paymentType && isset(self::$_paymentTypeArr[$paymentType])) { $paymentType = self::$_paymentTypeArr[$paymentType]; } //判断是否为创建暂停投放 $isPause = 1 == $op && 3 == $status ? 1 : 0; $item = array('Id' => $id); if ($name) { #投放名称 $item['Name'] = $name; } if ($orderId) { #订单id $item['CampaignId'] = $orderId; } if ($price) { #投放金额 $item['Chargeable'] = $price; } if ($paymentType) { #投放计费方式 $item['Payment'] = $paymentType; } if ($status) { #投放状态 $item['Status'] = $isPause ? 1 : $status; } //计费方式对用默认 $chargeType = false; #投放方式 1-按展开 2-按点击 3-按比例 $priority = false; #优先级 $budgetArr = array(); #计划投放量 if ($paymentType) { switch ($paymentType) { case 1: #CPM $chargeType = 1; #投放方式 按展开 $priority = 8; #优先级 8默认 $budgetArr = array('Type' => 0, 'Count' => 0); break; case 2: #CPC $chargeType = 2; #投放方式 按点击 $priority = 8; #优先级 8默认 $budgetArr = array('Type' => 0, 'Count' => 0); break; case 3: #CPD $chargeType = 3; #投放方式 按比例 $priority = 0; #优先级 $budgetArr = array('Type' => 2, 'Count' => 100); break; default: break; } } if ($chargeType) { #投放方式 $item['ChargeType'] = $chargeType; } if ($priority) { #优先级 $item['Priority'] = $priority; } if ($budgetArr) { #计划投放量 $item['Budget'] = $budgetArr; } if ($dateArr) { #排期 $tempDateArr = array(); foreach ($dateArr as $row) { $tempDateArr[] = array('StartTime' => $row[0] . ' 00:00:00', 'EndTime' => $row[1] . ' 23:59:59'); } $item['PartialDates'] = $tempDateArr; } if ($target) { #定向 $item['Targets'] = array(array('__type' => 'RegionTarget:#Asp.Business', 'Type' => 1, 'Enabled' => 'true', 'Value' => $target, 'IsInclude' => 'true')); } else { if (2 == $op) { $item['Targets'] = array(array('__type' => 'RegionTarget:#Asp.Business', 'Type' => 1, 'Enabled' => 'false')); } } if ($placeIdArr) { #广告位信息 $tempArr = array(); $i = 0; foreach ($placeIdArr as $id => $enabled) { $tempArr[$i]['Adspace']['Id'] = $id; $tempArr[$i]['Enabled'] = $enabled ? 'true' : 'false'; $i++; } $item['AdspaceMediabuys'] = $tempArr; } if ($adspaceIdArr) { #组合创意信息 #获取创意信息 $tempIdArr = array_keys($adspaceIdArr); $isMoreId = 1 == count($tempIdArr) ? 0 : 1; $adspaceArr = self::getCreative(array('id' => implode(',', $tempIdArr))); $creativeTypeArr = array(); if ($isMoreId) { foreach ($adspaceArr as $row) { $creativeTypeArr[$row['Id']] = $row['__type']; } } else { $creativeTypeArr[$adspaceArr['Id']] = $adspaceArr['__type']; } $tempArr = array(); $i = 0; foreach ($adspaceIdArr as $id => $enabled) { $tempArr[$i]['Creative']['__type'] = isset($creativeTypeArr[$id]) ? $creativeTypeArr[$id] : 'HtmlCreative:#Asp.Business'; $tempArr[$i]['Creative']['Id'] = $id; $tempArr[$i]['Enabled'] = $enabled ? 'true' : 'false'; $i++; } $item['AdspaceMediabuyCreatives'] = $tempArr; } /*if ($placeId) { #广告位信息 $tempArr = array(); $placeIdArr = explode(',', $placeId); foreach ($placeIdArr as $key=>$id) { $tempArr[$key]['Adspace']['Id'] = $id; $tempArr[$key]['Enabled'] = 'true'; } $item['AdspaceMediabuys'] = $tempArr; } if ($adspaceId) { //组合创意信息 $tempArr = array(); $adspaceIdArr = explode(',', $adspaceId); foreach ($adspaceIdArr as $key=>$id) { $tempArr[$key]['Creative']['__type'] = 'HtmlCreative:#Asp.Business'; $tempArr[$key]['Creative']['Id'] = $id; $tempArr[$key]['Enabled'] = 'true'; } $item['AdspaceMediabuyCreatives'] = $tempArr; }*/ //if ($frequencyArr) { #投放频次 // $item['Frequency'] = array('Enabled'=>FALSE, $frequencyArr); //} $json = '[{"Mediabuy":' . api_json_encode($item) . ',"Operator":' . $op . '}]'; $data = self::postData(array('url' => "MediabuyService.svc/MutateMediabuy", 'postdata' => $json)); if ($data) { $data = api_json_decode($data, true); if (!empty($data['PartialFailureErrors'])) { API_Libs_Global_Log::set(array('module' => 'adChinaPlace', 'content' => array('#I#' => is_array($options) ? api_json_encode($options) : '', '#P#' => $json, '#E#' => api_json_encode($data['PartialFailureErrors'])))); } if ($data && $data['Value']) { $retArr = $data['Value'][0]; //创建暂停推广时 if ($isPause) { if (isset($retArr['Id'])) { $editData = self::mutateMediabuy(array('op' => 'edit', 'id' => $retArr['Id'], 'status' => 3)); if ($editData) { $retArr['Status'] = $editData['Status']; } } } return $retArr; } } else { API_Libs_Global_Log::set(array('module' => 'adChinaPlace', 'content' => array('#I#' => is_array($options) ? api_json_encode($options) : '', '#P#' => $json, '#E#' => api_json_encode($data['PartialFailureErrors'])))); } }
/** * 将数组装换的首字母分装的数组 */ public static function transFirstLetterArr($paramArr) { $options = array('data' => array(), 'type' => 1, 'sel' => false); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); $outArr = array(); if ($data) { if ($type == 1) { #1:默认select 形式 return api_json_encode($data); } elseif ($type == 3) { #原生态select的option $out = ''; foreach ($data as $k => $wd) { $seled = $sel == $k ? "selected" : ""; $out .= "<option value='{$k}' {$seled}>{$wd}</option>"; } return mb_convert_encoding($out, "UTF-8", "GBK"); } elseif ($type == 2) { #div select 形式 foreach ($data as $k => $wd) { $l = API_Item_Base_String::getFirstLetter(array('input' => $wd)); #获得首字母 if (!isset($outArr[$l])) { $outArr[$l] = array('name' => $l, 'cons' => array()); } $outArr[$l]['cons'][] = $wd; } //var_dump($outArr); sort($outArr); return api_json_encode($outArr); } elseif ($type == 4) { #原生态select,按照字母排序的 foreach ($data as $k => $wd) { $l = API_Item_Base_String::getFirstLetter(array('input' => $wd)); #获得首字母 $outArr[$k] = $l . "_" . $wd; } asort($outArr); $out = ''; foreach ($outArr as $k => $wd) { $seled = $sel == $k ? "selected" : ""; $out .= "<option value='{$k}' {$seled}>{$wd}</option>"; } return $out; } } return ''; }
"type":"click", "name":"今日歌曲", "key":"V1001_TODAY_MUSIC" }, { "name":"菜单", "sub_button":[ { "type":"view", "name":"搜索", "url":"http://www.soso.com/" }, { "type":"view", "name":"视频", "url":"http://v.qq.com/" }, { "type":"click", "name":"赞一下我们", "key":"V1001_GOOD" }] }] }'; //获得一个AccessToken $accessToken = API_Item_Open_Weixin::getAccessToken(array('appId' => AppID, 'appSecret' => AppSecret)); $menuData = array('button' => array(array('name' => '会员', 'sub_button' => array(array('type' => 'click', 'name' => 'AA1', 'key' => 'BTN_MEMBER_VIEWSCORE'), array('type' => 'view', 'name' => 'AA2', 'url' => 'http://m.zol.com.cn/'), array('type' => 'scancode_push', 'name' => 'AA3', "key" => "rselfmenu_0_1", "sub_button" => array()))), array('name' => 'BB', 'sub_button' => array(array('type' => 'pic_sysphoto', 'name' => 'BB1', "key" => "rselfmenu_1_1", "sub_button" => array()), array('type' => 'pic_photo_or_album', 'name' => 'BB2', "key" => "rselfmenu_1_2", "sub_button" => array()), array('type' => 'location_select', 'name' => 'BB3', "key" => "rselfmenu_1_3", "sub_button" => array()))))); $menuData = api_json_encode($menuData); //创建菜单 $msg = API_Item_Open_Weixin::createManu(array('appId' => AppID, 'appSecret' => AppSecret, 'data' => $menuData)); var_dump($msg);