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


PHP response::getEncode方法代码示例

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


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

示例1: check

 public function check()
 {
     $this->params['app_id'] = $appid = isset($_POST['app_id']) ? $_POST['app_id'] : '';
     $this->params['version_id'] = $versionid = isset($_POST['version_id']) ? $_POST['version_id'] : '';
     $this->params['version_mini'] = $versionmini = isset($_POST['version_mini']) ? $_POST['version_mini'] : '';
     $this->params['did'] = $did = isset($_POST['did']) ? $_POST['did'] : '';
     $this->params['encrypt_did'] = $encryptdid = isset($_POST['encrypt_did']) ? $_POST['encrypt_did'] : '';
     // 接口数据校验省略,实际使用时须加
     if (!is_numeric($appid)) {
         response::getEncode(300, 'params error', '');
         exit;
     }
     // 判断APP是都要加密
     $this->app = $this->getApp($appid);
     if (!$this->app) {
         response::getEncode(500, 'params error', '');
         exit;
     }
     /*
     if($encryptdid!=md5($did,$this->app['key'])){
         response::getEncode(500,'md5 error','');
         exit();
     }
     */
 }
开发者ID:tanhaipeng,项目名称:APP_API,代码行数:25,代码来源:Common.class.php

示例2: index

 public function index()
 {
     // app请求参数校验
     $this->check();
     $error = isset($_POST['error_log']) ? $_POST['error_log'] : '';
     if (!$error) {
         response::getEncode(0, 'logs empty', '');
         exit;
     }
     $sql = "insert into log(error) values('start error')";
     $connect = DB::getInstance()->connect($dbConfig);
     mysqli_query($connect, $sql);
     response::getEncode(0, 'logs send success', '');
     exit;
 }
开发者ID:tanhaipeng,项目名称:APP_API,代码行数:15,代码来源:error.php

示例3: get

 public function get()
 {
     if (!is_numeric($this->_page) || !is_numeric($this->_pagesize)) {
         response::getEncode(100, 'request error', '');
         exit;
     }
     // get from cache
     global $dbConfig;
     global $cacheConfig;
     $cache = new Cache();
     $rdata = array();
     // 存在缓存时,直接获取缓存并返回
     /*
     if($rdata=$cache->cacheData('index_cache_'.$this->_page.'-'.$this->_pagesize)){
         response::getEncode(0,'request success',$rdata);
         exit();
     }
     */
     // 使用memcache缓存
     $this->_memcache->connect($cacheConfig['host'], $cacheConfig['port']);
     if ($rdata = $this->_memcache->get('index_cache_' . $this->_page . '-' . $this->_pagesize)) {
         var_dump('get cache');
         response::getEncode(0, 'request success', $rdata);
         exit;
     }
     // 否则读取数据库,并且更新缓存
     $offset = ($this->_page - 1) * $this->_pagesize;
     $sql = "select * from mall where status=1 order by price limit " . $offset . ',' . $this->_pagesize;
     // 异常接收
     try {
         $conn = DB::getInstance()->connect($dbConfig);
     } catch (Exception $e) {
         // $e->getMessage()
         response::getEncode(400, 'database connect error', '');
         exit;
     }
     $res = mysqli_query($conn, $sql);
     while ($row = mysqli_fetch_assoc($res)) {
         $rdata[] = $row;
     }
     //$cache->cacheData('index_cache_'.$this->_page.'_'.$this->_pagesize,$rdata,$cacheConfig['expiretime']);
     $this->_memcache->add('index_cache_' . $this->_page . '-' . $this->_pagesize, $rdata);
     var_dump('set cache');
     response::getEncode(0, 'request success', $rdata);
     exit;
 }
开发者ID:tanhaipeng,项目名称:APP_API,代码行数:46,代码来源:firstpage.class.php

示例4: isset

<?php

/**
 * get
 * http://***?type=firstpage&page=1&pagesize=10
 */
require_once 'Controllers/firstpage.class.php';
require_once 'Controllers/defaultpage.class.php';
require_once 'libs/Response.class.php';
// route
$type = isset($_GET['type']) ? $_GET['type'] : 'default';
switch ($type) {
    case 'firstpage':
        $firstpage = new firstpage();
        return $firstpage->get();
        break;
    default:
        $res = new response();
        return response::getEncode(200, 'request type error', '');
        break;
}
开发者ID:tanhaipeng,项目名称:APP_API,代码行数:21,代码来源:api.php


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