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


PHP responseJSON函数代码示例

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


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

示例1: header

header('Content-type: text/json; charset=UTF-8');
require_once "../include/global.include.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $returnArr = array('code' => 200);
    if (!check_session()) {
        responseJSON('session expired', 440);
    }
    extract($_POST);
    if (!isset($media_id)) {
        responseJSON('invalid request');
    }
    try {
        foreach ($media_id as $id) {
            $result = $wechat->dropMedia($id);
            if ($result['hasError']) {
                $returnArr = array('code' => 400, 'err' => $result['err']);
                break;
            }
            $query = 'UPDATE media_image SET deleted = 1 WHERE media_id = ?';
            if (!$mysql->execute($query, array($id))) {
                throw new Exception($mysql->error);
            }
        }
    } catch (Exception $ex) {
        # log the exception
        log_error('media_image: drop', json_encode($media_id), $ex->getMessage());
        $returnArr = array('code' => 500, 'err' => $ex->getMessage());
    }
    responseJSON($returnArr);
}
开发者ID:alvin-ho,项目名称:wechat-custom-cms,代码行数:30,代码来源:drop.php

示例2: actionDelete

 public function actionDelete()
 {
     $id = $_POST['id'];
     $sql = "delete from convey_answers where id=" . $id;
     iQuery($sql);
     responseJSON(['success' => true]);
 }
开发者ID:lvchenbaby,项目名称:convey,代码行数:7,代码来源:AdminController.php

示例3: array

<?php

$json = array();
$json['message'] = $message;
$json['amazing_level'] = $json['message'] === null ? $productModel->product_mark : null;
$json['commentList'] = null;
if ($message === null) {
    foreach ($results as $key => $result) {
        $json['commentList'][$key]['id'] = $result['id'];
        $json['commentList'][$key]['text'] = $result['text'];
        $json['commentList'][$key]['create_time'] = $result['create_time'];
        $json['commentList'][$key]['amazing_level'] = $result['amazing_level'];
    }
}
$json = JSON($json);
responseJSON($json);
开发者ID:roychad,项目名称:ST_server,代码行数:16,代码来源:_customerList.php

示例4: header

<?php

header('Content-type: application/json; charset=UTF-8');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    require_once "../include/global.include.php";
    $returnArr = array('code' => 200);
    if (!check_session()) {
        $returnArr['code'] = 440;
        responseJSON('session expired', 440);
    }
    if (!isset($_FILES) || !isset($_GET['type'])) {
        die(json_encode(array('code' => 400, 'err' => 'Invalid request')));
    }
    $type = $_GET['type'];
    $file = $_FILES['Filedata'];
    $imageData = getimagesize($file['tmp_name']);
    $extension = image_type_to_extension($imageData[2]);
    $available_type = array('image', 'thumb', 'voice', 'video');
    try {
        if (!in_array($type, $available_type)) {
            die(json_encode(array('code' => 400, 'err' => 'Invalid media type')));
        }
        // --------- save file in server -------------
        // the orignal filename
        $filename = $file['name'];
        // copy the file according to media type
        $targetPath = "/upload/{$type}/";
        $targetFileName = time() . $extension;
        $targetFile = dirname(__DIR__) . $targetPath . $targetFileName;
        if (!move_uploaded_file($file['tmp_name'], $targetFile)) {
            throw new Exception('file cannot be saved');
开发者ID:alvin-ho,项目名称:wechat-custom-cms,代码行数:31,代码来源:media_upload.php


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