• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP JsonResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: json

 /**
  * @param array $data
  * @param int $statusCode
  * @return Response
  */
 public static function json(array $data, $statusCode = 200)
 {
     $response = new JsonResponse();
     $response->setContent(json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT));
     $response->setHeader('Content-Type', 'application/json');
     $response->setStatusCode($statusCode);
     return $response;
 }
开发者ID:ivan-kolesov,项目名称:test-example,代码行数:13,代码来源:Response.php


示例2: areas

 public function areas()
 {
     $areas = $this->dao->getAreas();
     if ($areas->count() > 0) {
         return $this->returnJson($areas);
     }
     $json = new JsonResponse();
     return $json->response(false, "Nenhuma área encontrada!")->serialize();
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:9,代码来源:Controller.php


示例3: getMenusAction

 /**
  * Get memus - Makes search bar work.
  */
 public function getMenusAction()
 {
     $menusData = array();
     $systemTableService = $this->get('SystemTableService');
     $menus = $systemTableService->getMenus();
     foreach ($menus as $menu) {
         $menusData[] = array('id' => $menu->getId(), 'name' => $menu->getName());
     }
     $response = new JsonResponse();
     $response->setData($menusData);
     return $response;
 }
开发者ID:pavsuri,项目名称:PARMT,代码行数:15,代码来源:DefaultController.php


示例4: updateCostosAction

 public function updateCostosAction($id, $hash)
 {
     $today = new \DateTime();
     if ($hash != md5($today->format('Y-m-d'))) {
         $logger = $this->get('logger');
         $logger->error('Access denied on updateCostosAction');
         $returnJson = new JsonResponse();
         $returnJson->setData(array('ok' => true));
         return $returnJson;
     }
     $migrationService = $this->get('kinder.migrations');
     $migrationService->updateCostos();
     $returnJson = new JsonResponse();
     $returnJson->setData(array('ok' => true));
     return $returnJson;
 }
开发者ID:rsantellan,项目名称:bunnies-kinder2,代码行数:16,代码来源:MigrationCodiguerasController.php


示例5: datesIncluded

 public static function datesIncluded()
 {
     if (!isset($_REQUEST[START_DATE], $_REQUEST[END_DATE])) {
         echo JsonResponse::error("Incomplete request parameters!");
         exit;
     }
 }
开发者ID:ademolaoduguwa,项目名称:pms,代码行数:7,代码来源:ReportController.php


示例6: parseException

 protected function parseException()
 {
     /** @var APIResponse $response */
     $response = app(APIResponse::class);
     $fe = FlattenException::create($e);
     $data = env("APP_DEBUG", false) ? $fe->toArray() : ["message" => "whoops, something wrong."];
     return JsonResponse::create($data, 500);
 }
开发者ID:chatbox-inc,项目名称:lumen-app,代码行数:8,代码来源:Handler.php


示例7: run

 public function run(Request $request)
 {
     $queueRepository = \Contao\Doctrine\ORM\EntityHelper::getRepository('Avisota\\Contao:Queue');
     $queueId = $request->get('id');
     $queue = $queueRepository->find($queueId);
     /** @var \Avisota\Contao\Entity\Queue $queue */
     if (!$queue) {
         header("HTTP/1.0 404 Not Found");
         echo '<h1>404 Not Found</h1>';
         exit;
     }
     $user = \BackendUser::getInstance();
     $user->authenticate();
     try {
         return $this->execute($request, $queue, $user);
     } catch (\Exception $exception) {
         $response = new JsonResponse(array('error' => sprintf('%s in %s:%d', $exception->getMessage(), $exception->getFile(), $exception->getLine())), 500);
         $response->prepare($request);
         return $response;
     }
 }
开发者ID:Ainschy,项目名称:contao-core,代码行数:21,代码来源:AbstractQueueWebRunner.php


示例8: recv

 public function recv()
 {
     $rawResponse = '';
     do {
         $bytesRead = $this->clientSocket->read($buffer, 1024);
         if ($bytesRead > 0) {
             $rawResponse .= $buffer;
         } else {
             break;
         }
     } while ($rawResponse[strlen($rawResponse) - 1] != '\\n');
     if ($rawResponse) {
         return JsonResponse::parse($rawResponse);
     }
     return null;
 }
开发者ID:Athorcis,项目名称:athorrent-frontend,代码行数:16,代码来源:JsonClient.php


示例9: JsonResponse

<?php

$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, 'subarea', 'year', 'publication_type')) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, 'subarea', 'year', 'publication_type')) {
        require_once 'File.php';
        require_once 'PublicationController.php';
        require_once 'Publication.php';
        require_once 'Paper.php';
        require_once 'PublicationDao.php';
        require_once '../core/generics/SubArea.php';
        //require_once '../core/generics/State.php';
        require_once '../core/generics/PublicationType.php';
        //$jsonResponse = new JsonResponse();
        $file = $_FILES['Arquivo'];
        $controller = new PublicationController(new PublicationDao(Connection::connect()));
        $controller->setPath("../publicacao/");
        $publicationType = new PublicationType(null, $_POST['publication_type']);
        $publication = new Paper($_POST['title'], new SubArea(null, $_POST['subarea']), new File($file), null, date("Y-m-d"), null, $publicationType, $_POST['year']);
        //print_r($jsonResponse->response(false, $publication->getTypeId())->withoutHeader()->serialize());
        try {
            $controller->savePaper($publication);
            print_r($jsonResponse->response(true, "Arquivo enviado com sucesso!")->withoutHeader()->serialize());
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->withoutHeader()->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "Todos os campos devem ser preenchidos e/ou marcados.")->withoutHeader()->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros não configurados corretamente.")->withoutHeader()->serialize());
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:31,代码来源:save-paper.php


示例10: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2015 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
//$ses=Session::getInstance();
$toReturn = new JsonResponse();
if (isset($_POST['email']) && trim($_POST['email']) != '') {
    // send email to support
    $info['product'] = $_POST['product'];
    $info['version'] = $_POST['version'];
    $info['username'] = $_POST['userName'];
    $info['email'] = $_POST['email'];
    $user = new User($dbConnectionInfo);
    $generateInfo = $user->generatePasswd($info);
    $productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $info['product'];
    if ($generateInfo['generated'] == "") {
        // nu are email valid
        $toReturn->set("success", "false");
        $toReturn->set("message", Utils::translate('noEmailFound'));
        //echo "No ";
    } else {
        if ($generateInfo['match']) {
            // generated password
            $template = new Template("./templates/" . __LANGUAGE__ . "/recover.html");
            $confirmationMsg = $template->replace(array("username" => $info['username'], "password" => $generateInfo['generated'], "productName" => $productTranslate));
开发者ID:bdensmore,项目名称:dita-docs,代码行数:31,代码来源:recover.php


示例11: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once "init.php";
$cfgFile = './config/config.php';
$cfgInstall = '../../install/';
$toReturn = new JsonResponse();
if (file_exists($cfgInstall)) {
    $toReturn->set("installPresent", "true");
} else {
    $toReturn->set("installPresent", "false");
}
if (file_exists($cfgFile) && filesize($cfgFile) > 0) {
    $toReturn->set("configPresent", "true");
} else {
    $toReturn->set("configPresent", "false");
}
echo $toReturn;
开发者ID:phoenix-mossimo,项目名称:BTS-Manual,代码行数:24,代码来源:checkInstall.php


示例12: elseif

        $toReturn->set("name", $ses->{$fullUser}->name);
        $toReturn->set("userName", $ses->{$fullUser}->userName);
        $toReturn->set("level", $ses->{$fullUser}->level);
    } else {
        if (strlen(trim($user->msg)) > 0) {
            $toReturn->set("error", $user->msg);
        }
    }
    echo $toReturn;
} elseif (isset($_POST['logOff']) && trim($_POST['logOff']) != '') {
    $ses->errBag = null;
    unset($ses->errBag);
    unset($ses->{$fullUser});
    // 		echo print_r($_POST,true);
} elseif (isset($_POST['check']) && trim($_POST['check']) != '') {
    $toReturn = new JsonResponse();
    $toReturn->set("isAnonymous", "false");
    $toReturn->set("loggedIn", "false");
    if (defined('__GUEST_POST__') && !__GUEST_POST__ && (isset($ses->{$fullUser}) && $ses->{$fullUser}->isAnonymous == 'true')) {
        unset($ses->{$fullUser});
    }
    if (defined('__GUEST_POST__') && __GUEST_POST__ && !isset($ses->{$fullUser})) {
        $user = new User($dbConnectionInfo);
        // user not logged in and guest is allowed to post
        if (!$user->initAnonymous()) {
            $toReturn->set("isAnonymous", "false");
            $toReturn->set("loggedIn", "false");
            $toReturn->set("msg", "1");
            $toReturn->set("msgType", "error");
        } else {
            // anonymous must be logged in
开发者ID:aidanreilly,项目名称:documentation,代码行数:31,代码来源:checkUser.php


示例13: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
$toReturn = new JsonResponse();
if (isset($_POST['id']) && trim($_POST['id']) != '') {
    $realId = base64_decode($_POST['id']);
    //list($id,$date,$action,$newPassword) = explode("|", $realId);
    $args = explode("|", $realId);
    $id = $args[0];
    $date = $args[1];
    $action = "new";
    $newPassword = "";
    if (count($args) > 2) {
        $action = $args[2];
        $newPassword = $args[3];
    }
    $user = new User($dbConnectionInfo);
    //echo "id=".$id." date=".$date;
    $currentDate = date("Y-m-d G:i:s");
    $days = Utils::getTimeDifference($currentDate, $date, 3);
    if ($days > 7) {
        $toReturn->set("error", true);
        $toReturn->set("msg", "Confirmation code expired!");
    } else {
开发者ID:phoenix-mossimo,项目名称:BTS-Manual,代码行数:31,代码来源:confirmUser.php


示例14: toJson

 /**
  * Helper method to return a JSON response.
  *
  * @param mixed $data
  *  The data to return as the response.
  * @param int $status
  *  The HTTP status code for this response.
  *
  * @return JsonResponse
  *
  */
 public function toJson($data, $status = 200)
 {
     return JsonResponse::create($data, $status);
 }
开发者ID:krisolafson,项目名称:restapi,代码行数:15,代码来源:HttpResponseFactory.php


示例15: elseif

        if ($response) {
            echo JsonResponse::success("Profile Successfully Updated!");
            exit;
        } else {
            echo JsonResponse::error("Could not update Profile. Please try again!");
            exit;
        }
    } else {
        echo JsonResponse::error("Profile data not set");
        exit;
    }
} elseif ($intent == 'getProfile') {
    if (isset($_REQUEST['userid'])) {
        $userid = $_REQUEST['userid'];
        $userController = new UserController();
        $profile = $userController->getUserProfile($userid);
        if ($profile && is_array($profile)) {
            echo JsonResponse::success($profile);
            exit;
        } else {
            echo JsonResponse::error("Could not fetch user profile. Please try again later.");
            exit;
        }
    } else {
        echo JsonResponse::error("Expected parameter not set");
        exit;
    }
} else {
    echo JsonResponse::error('Invalid intent!');
    exit;
}
开发者ID:ademolaoduguwa,项目名称:pms,代码行数:31,代码来源:phase_profile.php


示例16: elseif

        $response = $warden->deleteBed($_POST[BedTable::bed_id]);
        if (is_array($response)) {
            echo JsonResponse::error($response[P_MESSAGE]);
            exit;
        } else {
            echo JsonResponse::message(STATUS_OK, "Bed successfully deleted!");
            exit;
        }
    } else {
        echo JsonResponse::error("Incomplete request parameters!");
        exit;
    }
} elseif ($intent == 'deleteWard') {
    if (isset($_POST[WardRefTable::ward_ref_id])) {
        $warden = new WardController();
        $response = $warden->deleteWard($_POST[WardRefTable::ward_ref_id]);
        if (is_array($response)) {
            echo JsonResponse::error($response[P_MESSAGE]);
            exit;
        } else {
            echo JsonResponse::message(STATUS_OK, "Ward deletion successful!");
            exit;
        }
    } else {
        echo JsonResponse::error("Incomplete request parameters!");
        exit;
    }
} else {
    echo JsonResponse::error("Invalid intent!");
    exit;
}
开发者ID:ademolaoduguwa,项目名称:pms,代码行数:31,代码来源:phase_ward.php


示例17: JsonResponse

<?
    require_once '../core/generics/Param.php';
    require_once '../core/generics/datacenter/Country.php';
    require_once '../core/generics/Controller.php';
    require_once '../core/generics/GenericDao.php';        
    
    $json = new JsonResponse();
    
    if(RequestsPatterns::postParamsSetted('name', 'type')){
        if(RequestsPatterns::postParamsSent('name', 'type')){
            $name = $_POST['name'];
            $typeCountry = $_POST['type'];
            
            $country = new Country($name);
             
            $dao = new GenericDao(Connection::connect());
            $controller = new Controller($dao);
            
            $message = "País inserido com sucesso";
            $message_error = "Falha na inserção do país"; 
            try{
                if($typeCountry == 'origin'){
                    if(isset($_POST['reexport']) && $_POST['reexport'] == true){
                        $country->setReexport();
                    }
                    if($controller->createNewOriginCountry($country)){
                        $countryToCache = $controller->getCountryByName($country,$typeCountry);                        
                        cacheCountry($countryToCache, $typeCountry);
                        print_r($json->response (true, $message)->serialize ());
                    }else
                        print_r($json->response (true, $message_error)->serialize ());
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:31,代码来源:country_insert.php


示例18: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
//$ses=Session::getInstance();
$json = new JsonResponse();
if (isset($_POST['userName']) && trim($_POST['userName']) != '') {
    // send email to support
    $info['username'] = $_POST['userName'];
    $info['name'] = $_POST['name'];
    $info['password'] = $_POST['password'];
    $info['email'] = $_POST['email'];
    $user = new User($dbConnectionInfo);
    $return = $user->insertNewUser($info);
    if ($return->error == "true") {
        echo $return;
    } else {
        $id = base64_encode($user->userId . "|" . $user->date);
        $link = "<a href='" . __BASE_URL__ . "oxygen-webhelp/resources/confirm.html?id={$id}'>" . __BASE_URL__ . "oxygen-webhelp/resources/confirm.html?id={$id}</a>";
        $template = new Template("./templates/signUp.html");
        $productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $_POST['product'];
        $arrayProducts = $user->getSharedProducts();
        $products = "";
        foreach ($arrayProducts as $productId => $productName) {
            $products .= "\"" . $productName . "\" ";
开发者ID:aidanreilly,项目名称:documentation,代码行数:31,代码来源:signUp.php


示例19: JsonResponse

<?php

require_once 'util/RequestsPatterns.php';
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted('title', 'text', 'analysis_id')) {
    if (RequestsPatterns::postParamsSent('title', 'text', 'analysis_id')) {
        if (Session::isLogged()) {
            require_once 'core/User/User.php';
            require_once 'Publication.php';
            require_once 'Analyse.php';
            require_once 'PublicationController.php';
            require_once 'PublicationDao.php';
            require_once 'Comment.php';
            $user = Session::getLoggedUser();
            $analysis = new Analyse(null);
            $analysis->setId($_POST['analysis_id']);
            $user->comment(new Comment(date("Y-m-d H:i:s"), $_POST['title'], $_POST['text']), $analysis);
            $controller = new PublicationController(new PublicationDao(Connection::connect()));
            try {
                if ($controller->comment($analysis)) {
                    print_r($jsonResponse->response(true, "Comentário enviado com sucesso!")->serialize());
                } else {
                    print_r($jsonResponse->response(false, "Falha ao eviar comentário. Tente novamente")->serialize());
                }
            } catch (Exception $err) {
                print_r($jsonResponse->response(false, $err->getMessage())->serialize());
            }
        } else {
            print_r($jsonResponse->response(false, "Faça o login para poder deixar seu comentário")->serialize());
        }
    } else {
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:31,代码来源:comment_analysis.php


示例20: JsonResponse

<?php

$jsonResponse = new JsonResponse();
$_POST['fromAdmin'] = true;
//require_once 'build.php';
require_once 'requires_build.php';
if (RequestsPatterns::postParamsSetted('subgroup', 'font', 'coffetype', 'variety', 'destiny')) {
    if (RequestsPatterns::postParamsSent('subgroup', 'font', 'coffetype', 'variety', 'destiny')) {
        require_once '../core/Exceptions/WrongTypeException.php';
        require_once '../core/Exceptions/WrongFormatException.php';
        require_once '../core/Datacenter/CountryMap.php';
        require_once '../util/excel/reader/ExcelInputFile.php';
        require_once '../util/excel/reader/SpreadsheetValidator.php';
        require_once '../util/excel/reader/excel_reader2.php';
        $file = $_FILES['Planilha']['tmp_name'];
        $subgroup = $_POST['subgroup'];
        $font = $_POST['font'];
        $coffeType = $_POST['coffetype'];
        if ($coffeType == 'none') {
            $coffeType = 0;
        }
        $variety = $_POST['variety'];
        if ($variety == "none") {
            $variety = 0;
        }
        $destiny = $_POST['destiny'];
        $origin = $_POST['origin'];
        $typeCountry = null;
        if (isset($_POST['typeCountry'])) {
            $typeCountry = $_POST['typeCountry'];
        }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:31,代码来源:insert_values.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Jtext类代码示例发布时间:2022-05-23
下一篇:
PHP JsonHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap