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


PHP response::json方法代码示例

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


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

示例1: index

 public function index()
 {
     $users = $this->users()->map(function ($user) {
         return api::user($user);
     });
     return response::json(array_values($users->toArray()));
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:7,代码来源:users.php

示例2: afterRoute

 /**
  * compile and send the json response.
  */
 public function afterRoute($f3, $params)
 {
     $version = (int) $f3->get('GET.version');
     if (empty($version)) {
         $version = $this->version;
     }
     if ($version !== $this->version) {
         $this->failure(4999, 'Unknown API version requested.', 400);
     }
     if (empty($this->data['href'])) {
         $data['href'] = $this->href();
     }
     $data = array('service' => 'API', 'api' => $version, 'time' => time()) + $this->data;
     // if an OAuthError is set, return that instead of errors array
     if (!empty($this->OAuthError)) {
         $data['error'] = $this->OAuthError;
     } else {
         if (count($this->errors)) {
             ksort($this->errors);
             $data['errors'] = $this->errors;
         }
     }
     $return = $f3->get('GET.return');
     switch ($return) {
         case 'xml':
             $this->response->xml($data, $this->params);
             break;
         default:
         case 'json':
             $this->response->json($data, $this->params);
     }
 }
开发者ID:andydwilliams,项目名称:f3-boilerplate,代码行数:35,代码来源:Api.php

示例3: ajaxCouponData

 public function ajaxCouponData()
 {
     $filter = input::get();
     if (!$filter['pages']) {
         $filter['pages'] = 1;
     }
     $pageSize = 10;
     $params = array('page_no' => $pageSize * ($filter['pages'] - 1), 'page_size' => $pageSize, 'fields' => '*', 'user_id' => userAuth::id());
     $couponListData = app::get('topm')->rpcCall('user.coupon.list', $params, 'buyer');
     $count = $couponListData['count'];
     $couponList = $couponListData['coupons'];
     //处理翻页数据
     $current = $filter['pages'] ? $filter['pages'] : 1;
     $filter['pages'] = time();
     if ($count > 0) {
         $total = ceil($count / $pageSize);
     }
     $pagedata['pagers'] = array('link' => url::action('topm_ctl_member_coupon@couponList', $filter), 'current' => $current, 'total' => $total, 'token' => $filter['pages']);
     $pagedata['couponList'] = $couponList;
     $pagedata['count'] = $count;
     $pagedata['action'] = 'topm_ctl_member_coupon@couponList';
     if (input::get('json')) {
         $data['html'] = view::make('topm/member/coupon/list.html', $pagedata)->render();
         $data['pagers'] = $pagedata['pagers'];
         $data['success'] = true;
         return response::json($data);
         exit;
     }
     return view::make('topm/member/coupon/list.html', $pagedata);
 }
开发者ID:453111208,项目名称:bbc,代码行数:30,代码来源:coupon.php

示例4: getProp

 public function getProp()
 {
     $postCartId = input::get('catId');
     try {
         $userMdlProp = app::get("syscategory")->model('cat_rel_prop');
         $propList = $userMdlProp->getList("*", array('cat_id' => $postCartId));
         $pagedata = array();
         foreach ($propList as $prop) {
             // code...
             $propId = $prop["prop_id"];
             $propModel = app::get("syscategory")->model('prop_values');
             $propValueList = $propModel->getList("*", array('prop_id' => $propId));
             foreach ($propValueList as $propvalue) {
                 $pagedata[] = array("prop_value_id" => $propvalue["prop_value_id"], "prop_value" => $propvalue["prop_value"]);
             }
             $a = 1;
         }
     } catch (Exception $e) {
         $msg = $e->getMessage();
         return $this->splash('error', null, $msg);
     } catch (\LogicException $e) {
         $msg = $e->getMessage();
         return $this->splash('error', null, $msg);
     }
     $ajaxdata = array('datas' => $pagedata);
     return response::json($ajaxdata);
 }
开发者ID:453111208,项目名称:bbc,代码行数:27,代码来源:goods.php

示例5: ajaxTrade

 /**
  * 异步获取数据  图表用
  * @param null
  * @return array
  */
 public function ajaxTrade()
 {
     $postData = input::get();
     //api的参数
     $all = $this->__getParams('graphall', $postData, 'trade');
     $datas = app::get('topshop')->rpcCall('sysstat.data.get', $all, 'seller');
     return response::json($datas);
 }
开发者ID:453111208,项目名称:bbc,代码行数:13,代码来源:sysbusiness.php

示例6: getItemPic

 /**
  * 根据itemId获取图片
  */
 public function getItemPic()
 {
     $itemId = input::get('itemIds');
     $picData = kernel::single('sysitem_item_info')->getItemDefaultPic($itemId);
     if ($picData[$itemId]['image_default_id']) {
         $result['url'] = $picData[$itemId]['image_default_id'];
     }
     return response::json($result);
 }
开发者ID:453111208,项目名称:bbc,代码行数:12,代码来源:image.php

示例7: ajaxTrade

 /**
  * 异步获取数据  图表用
  * @param null
  * @return array
  */
 public function ajaxTrade()
 {
     $postData = input::get();
     $orderBy = $postData['trade'] . ' ' . 'DESC';
     $postData['orderBy'] = $orderBy;
     $postData['limit'] = 10;
     $grapParams = $this->__getParams('itemgraphall', $postData, 'item');
     $datas = app::get('topshop')->rpcCall('sysstat.data.get', $grapParams, 'seller');
     $ajaxdata = array('dataInfo' => $data, 'datas' => $datas);
     return response::json($ajaxdata);
 }
开发者ID:453111208,项目名称:bbc,代码行数:16,代码来源:itemtrade.php

示例8: slideDelete

 public function slideDelete($id)
 {
     $result = false;
     $slide = Slide::where('id', $id);
     if ($slide) {
         $slide->delete();
         SlideImage::where('slide_id', $id)->delete();
         $result = true;
     }
     return response::json(array('result' => $result));
 }
开发者ID:ElliottLandsborough,项目名称:lararel-simple-library,代码行数:11,代码来源:AdminController.php

示例9: autocomplete

 public function autocomplete($mode)
 {
     switch ($mode) {
         case 'usernames':
             $result = site()->users()->map(function ($user) {
                 return $user->username();
             })->toArray();
             break;
         case 'emails':
             $result = site()->users()->map(function ($user) {
                 return $user->email();
             })->toArray();
             break;
         case 'uris':
             $result = site()->index()->map(function ($page) {
                 return $page->id();
             })->toArray();
             // sort results alphabetically
             sort($result);
             break;
         case 'field':
             $index = get('index', 'siblings');
             // siblings, children, template, all
             $id = get('uri');
             $page = page($id);
             switch ($index) {
                 case 'siblings':
                 case 'children':
                     $pages = $page->{$index}();
                     break;
                 case 'template':
                     $template = get('template', $page->template());
                     $pages = site()->index()->filterBy('template', $template);
                     break;
                 case 'pages':
                 case 'all':
                     $pages = site()->index();
                     break;
                 default:
                     if ($page = site()->page($index)) {
                         $pages = $page->children();
                     } else {
                         return response::json(array());
                     }
             }
             $result = $pages->pluck(get('field', 'tags'), get('separator', true), true);
             break;
         default:
             return response::error('Invalid autocomplete method');
     }
     return response::json(array_values($result));
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:52,代码来源:helpers.php

示例10: handle

 /**
  * Handle an incomming request.
  */
 public static function handle($pageId, $lang)
 {
     if (r::data('token') != c::get('slack.verify')) {
         return response::error('Forbidden', 403);
     }
     $history = static::api('channels.history', ['channel' => r::data('channel_id')]);
     if (!empty($history['error'])) {
         // Something went wrong ... maybe:
         $msg = ['channel_not_found' => ':lock: Sorry, but this is a private channel'];
         $err = $history['error'];
         return response::json(isset($msg[$err]) ? $msg[$err] : $err);
     }
     $messages = $history['messages'];
     if (!empty(r::data('text'))) {
         $messages = array_values(array_filter($messages, function ($m) {
             return stristr($m['text'], r::data('text'));
         }));
     }
     if (empty($messages)) {
         return response::json(":mag: Sorry, I couldn't find the post you're looking for");
     }
     $m = $messages[0];
     $a = @$m['attachments'][0];
     $img = @$a['image_url'];
     if (empty($img)) {
         $img = @$a['thumb_url'];
     }
     if (empty($img)) {
         return response::json(":warning: I'll only publish posts with images");
     }
     $page = site()->visit($pageId, $lang);
     $dir = $page->root();
     $ext = preg_replace('/.+?(\\.\\w+)($|[#?].*)/', '$1', $img);
     $file = $dir . DS . $m['ts'] . $ext;
     // Output success message early because of short slackbot timeouts
     $msg = ':metal: *' . r::data('text', 'last') . '* post is now live' . ' on <' . $page->url() . '>';
     echo $msg;
     flush();
     error_log($msg);
     $user = static::api('users.info', ['user' => $m['user']]);
     $meta = ['title' => $a['title'], 'date' => date('d.m.Y', $m['ts']), 'description' => @$a['text'], 'linkurl' => $a['from_url'], 'author' => $user['user']['profile']['real_name'], 'avatar' => $m['user'] . '.jpg', 'comment' => static::format(@$m['text']), 'slack' => '1'];
     data::write($file . '.txt', $meta, 'kd');
     // Download the avatar image
     $avatar = $dir . DS . $meta['avatar'];
     static::download($user['user']['profile']['image_72'], $avatar);
     // Download the image
     static::download($img, $file);
     // Response has already been sent
     return false;
 }
开发者ID:yours-truly,项目名称:kirby-slack,代码行数:53,代码来源:slack.php

示例11: setConf

 public function setConf()
 {
     $shopId = $this->shopId;
     $confs = input::get();
     try {
         $requestParams = ['shop_id' => $shopId, 'developMode' => $confs['developer'] ? $confs['developer'] : 'PRODUCT'];
         app::get('topshop')->rpcCall('open.shop.develop.setConf', $requestParams);
         $ret = ['result' => '修改成功'];
     } catch (Exception $e) {
         $ret = ['result' => $e->getMessage()];
     }
     return response::json($ret);
     exit;
 }
开发者ID:453111208,项目名称:bbc,代码行数:14,代码来源:open.php

示例12: getChildrenCatList

 /**
  * 根据父类id获取子类列表
  * @return json
  */
 public function getChildrenCatList()
 {
     $catId = intval(input::get('cat_id'));
     if ($catId) {
         $catList = app::get('toputil')->rpcCall('category.cat.get.info', array('parent_id' => $catId, 'fields' => 'cat_id,cat_name,child_count'));
         foreach ($catList as $key => $value) {
             $newList[$key] = array('value' => $value['cat_id'], 'text' => $value['cat_name'], 'hasChild' => $value['child_count'] > 0 ? true : false);
         }
         $data['data']['options'] = $newList;
     } else {
         $data = array();
     }
     return response::json($data);
 }
开发者ID:453111208,项目名称:bbc,代码行数:18,代码来源:syscat.php

示例13: handle

 public function handle($request, Clousure $next)
 {
     $routeAs = route::currentRouteName();
     $currentPermission = shopAuth::getSellerPermission();
     //$currentPermission = false 表示为店主不用判断权限
     //获取当前用户的路由权限
     if ($currentPermission && !in_array($routeAs, $currentPermission)) {
         if (request::ajax()) {
             return response::json(array('error' => true, 'message' => '无操作权限'));
         } else {
             return redirect::action('topshop_ctl_index@nopermission');
         }
     }
     return $next($request);
 }
开发者ID:453111208,项目名称:bbc,代码行数:15,代码来源:permission.php

示例14: splash

 public function splash($status = 'success', $url = null, $msg = null, $ajax = false)
 {
     $status = $status == 'failed' ? 'error' : $status;
     //如果需要返回则ajax
     if ($ajax == true || request::ajax()) {
         return response::json(array($status => true, 'message' => $msg, 'redirect' => $url));
     }
     if ($url && !$msg) {
         //如果有url地址但是没有信息输出则直接跳转
         return redirect::action($url);
     }
     $this->setLayoutFlag('splash');
     $pagedata['msg'] = $msg;
     return $this->page('topm/splash/error.html', $pagedata);
 }
开发者ID:453111208,项目名称:bbc,代码行数:15,代码来源:controller.php

示例15: update

 public function update()
 {
     $noticeid = $_POST["notice_id"];
     $noticemdl = app::get("sysshop")->model("shop_notice");
     $notice = $noticemdl->getRow("*", array("notice_id" => $noticeid));
     $notice["is_read"] = true;
     try {
         $noticemdl->save($notice);
         $ajaxdata["result"] = "success";
         return response::json($ajaxdata);
     } catch (Exception $e) {
         $ajaxdata["result"] = "error";
         return response::json($ajaxdata);
     }
 }
开发者ID:453111208,项目名称:bbc,代码行数:15,代码来源:notice.php


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