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

PHP json_response函数代码示例

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

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



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

示例1: OutputCSI

/**
 * Main function of this module which outputs csv as attachment or json/jsonp.
 */
function OutputCSI($id, $testPath, $run, $cached, $runs, $format)
{
    // Check whether a test-id and test-path are available.
    if (is_null($id) || is_null($testPath)) {
        header('HTTP/1.0 404 Not Found');
        return;
    }
    $data = null;
    if ($format == 'csv') {
        OutputCsvHeaders('csi.csv');
    } else {
        if ($format == 'json') {
            $data = array();
        }
    }
    // If it is for a particular run specified by the $run variable, then output
    // csi only for that run. Else, output for all.
    if (!is_null($_GET['run'])) {
        ParseCsiForRun($id, $testPath, $run, $cached, $data);
    } else {
        if ($runs) {
            for ($run = 1; $run <= $runs; $run++) {
                // First-view.
                ParseCsiForRun($id, $testPath, $run, FALSE, $data);
                // Repeat-view.
                ParseCsiForRun($id, $testPath, $run, TRUE, $data);
            }
        }
    }
    if ($format == 'json') {
        json_response($data);
    }
}
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:36,代码来源:google_csi.php


示例2: require_login_json

function require_login_json(&$app)
{
    if ($user = current_user()) {
        return $user;
    }
    json_response($app, array('error' => 'not_logged_in'));
    return false;
}
开发者ID:diplix,项目名称:Monocle,代码行数:8,代码来源:auth.php


示例3: index

 function index()
 {
     //
     cxp_update_cache($this->site_id);
     // $this->output->set_output('success');
     // $this->load->view('alert', $this->template_data);
     json_response(array('success' => FALSE, 'msg' => 'Success'));
 }
开发者ID:ishawge,项目名称:cxpcms,代码行数:8,代码来源:Clear_cache.php


示例4: json_success

function json_success($result, $id)
{
    $object = new stdClass();
    $object->error = null;
    $object->result = $result;
    $object->id = $id;
    json_response($object);
}
开发者ID:neofutur,项目名称:Bitcoin-mining-proxy,代码行数:8,代码来源:common.inc.php


示例5: deletePost

 /**
  * Deletes a specific post based on ID.
  *
  * @param $id
  * @param Http $http
  *
  * @return \Herbert\Framework\Response
  *
  * @throws HttpErrorException
  */
 public function deletePost($id, Http $http)
 {
     $this->allowed($http->ip());
     $deleted = ApiPost::query()->where('ID', $id)->delete();
     if ($deleted) {
         return json_response(['Success']);
     }
     return response('Nothing deleted', 404);
 }
开发者ID:PrafullaKumarSahu,项目名称:example-plugin,代码行数:19,代码来源:ApiController.php


示例6: change_password

 function change_password()
 {
     if (strtoupper($_SERVER['REQUEST_METHOD']) === 'POST') {
         $this->load->helper(array('server'));
         $this->form_validation->set_rules('password', 'New Password', 'trim|required');
         $this->form_validation->set_rules('confirmpassword', 'Confirm New Password', 'trim|required');
         if ($this->form_validation->run() === FALSE) {
             json_response(array('success' => FALSE, 'msg' => validation_errors()));
         } else {
             $user_id = intval($this->input->post('user_id'));
             $password = trim($this->input->post('password'));
             if ($user_id) {
                 $this->db->where('id', $user_id);
                 $data = array('password' => password_hash($password, PASSWORD_BCRYPT));
                 $this->db->update('users', $data);
                 json_response(array('success' => TRUE, 'msg' => 'Update Password Success'));
             } else {
                 json_response(array('success' => FALSE, 'msg' => 'Invalid'));
             }
         }
     } else {
         $user_id = intval($this->input->get('user_id'));
         $token_code = trim($this->input->get('token_code'));
         if ($user_id && $token_code) {
             $this->db->where('user_id', $user_id);
             $this->db->where('random_string', $token_code);
             $row = $this->db->get('forget_pwd')->row();
             if ($row) {
                 // valid link
                 // delete used rendom_string
                 $this->db->where('id', $row->id);
                 $this->db->delete('forget_pwd');
                 $data['success'] = TRUE;
                 $data['message'] = '';
                 $data['user_id'] = $row->user_id;
             } else {
                 //
                 $data['success'] = FALSE;
                 $data['message'] = 'Invalid Link';
             }
         } else {
             // invalid
             $data['success'] = FALSE;
             $data['message'] = 'Invalid Link';
         }
         $this->load->view('changepassword', $data);
     }
 }
开发者ID:ishawge,项目名称:cxpcms,代码行数:48,代码来源:Login.php


示例7: OT_customFShare

function OT_customFShare()
{
    $link = $_POST['link'];
    $like_array = json_response('http://graph.facebook.com/fql?q=SELECT%20url,%20share_count%20FROM%20link_stat%20WHERE%20url="' . $link . '"');
    if ($like_array != false) {
        if (isset($like_array->data[0]->share_count)) {
            $like_count = intval($like_array->data[0]->share_count);
        } else {
            $like_count = 0;
        }
        if (is_int($like_count)) {
            echo $like_count;
        } else {
            echo 0;
        }
    }
    die;
}
开发者ID:trantuanvn,项目名称:coffeeletsgo,代码行数:18,代码来源:ajax.php


示例8: json_response_error_alert

/**
 * An Error json response
 * @param $title
 * @param $content
 * @return \Illuminate\Http\JsonResponse
 */
function json_response_error_alert($title, $content = '')
{
    return json_response($title, $content, 'alert');
}
开发者ID:bpocallaghan,项目名称:titan,代码行数:10,代码来源:helpers.php


示例9: delete

 function delete()
 {
     check_permission('admin-del-role');
     $id = intval($this->input->get('id'));
     $this->db->trans_begin();
     $this->db->where('roleID', $id);
     $this->db->delete('role_perms');
     $this->db->where('roleID', $id);
     $this->db->delete('user_roles');
     //
     $this->db->where('id', $id);
     $this->db->delete('roles');
     $this->db->trans_complete();
     cxp_update_cache();
     json_response(array('success' => TRUE, 'msg' => 'Delete Role Success'));
 }
开发者ID:ishawge,项目名称:cxpcms,代码行数:16,代码来源:Roles.php


示例10: k

        $response = ['latitude' => null, 'longitude' => null, 'locality' => null, 'region' => null, 'country' => null, 'best_name' => null, 'full_name' => null, 'timezone' => null, 'offset' => null, 'seconds' => null, 'localtime' => null];
        if (k($params, 'input')) {
            $adr = p3k\Geocoder::geocode($params['input']);
        } else {
            $lat = (double) $params['latitude'];
            $lng = (double) $params['longitude'];
            $response['latitude'] = $lat;
            $response['longitude'] = $lng;
            $adr = p3k\Geocoder::adrFromLocation($lat, $lng);
        }
        if ($adr) {
            $response['latitude'] = $adr->latitude;
            $response['longitude'] = $adr->longitude;
            $response['locality'] = $adr->localityName;
            $response['region'] = $adr->regionName;
            $response['country'] = $adr->countryName;
            $response['best_name'] = $adr->bestName;
            $response['full_name'] = $adr->fullName;
        }
        $timezone = p3k\Timezone::timezone_for_location($response['latitude'], $response['longitude'], k($params, 'date'));
        if ($timezone) {
            $response['timezone'] = $timezone->name;
            $response['offset'] = $timezone->offset;
            $response['seconds'] = $timezone->seconds;
            $response['localtime'] = $timezone->localtime;
        }
        json_response($app, $response);
    } else {
        json_response($app, ['error' => 'invalid_request', 'error_description' => 'Request was missing parameters'], 400);
    }
});
开发者ID:aaronpk,项目名称:Atlas,代码行数:31,代码来源:geocode.php


示例11: changeOrderSections

/**
* @desc Modifica el orden de las secciones
**/
function changeOrderSections()
{
    global $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        json_response(__('Session token expired!', 'docs'), 1);
    }
    parse_str(rmc_server_var($_POST, 'items', ''));
    if (empty($list)) {
        json_response(__('Data not valid!', 'docs'), 1);
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $res = '';
    $pos = 0;
    foreach ($list as $id => $parent) {
        $parent = $parent == 'root' ? 0 : $parent;
        if ($parent == 0 && !is_object($res)) {
            $res = new RDSection($id);
        }
        $sql = "UPDATE " . $db->prefix("rd_sections") . " SET parent={$parent}, `order`={$pos} WHERE id_sec={$id}";
        $db->queryF($sql);
        $pos++;
    }
    json_response(__('Sections positions saved!', 'docs'), 0, $res->getVar('id_res'));
}
开发者ID:laiello,项目名称:bitcero-modules,代码行数:27,代码来源:sections.php


示例12: get_request_data

<?php

try {
    require "./db.php";
    $REQUEST = get_request_data();
    if (!array_key_exists('cohortid', $REQUEST)) {
        throw new Exception('Did not supply cohortid');
    }
    echo json_response('success', null, get_user_list($REQUEST['cohortid']));
} catch (Exception $e) {
    echo json_response('error', $e->getMessage(), null);
}
开发者ID:potch,项目名称:spenses,代码行数:12,代码来源:get_user_list.php


示例13: delete

 function delete()
 {
     check_permission('admin-del-event');
     $id = intval($this->input->get('id'));
     $this->db->where('id', $id);
     $this->db->where('user_id', $this->user->id);
     $this->db->delete('events');
     operation_log(array('user_id' => $this->user->id, 'content' => '删除事件:' . $id));
     json_response(array('success' => TRUE, 'msg' => '删除事件成功'));
 }
开发者ID:ishawge,项目名称:cxpcms,代码行数:10,代码来源:Calendar.php


示例14: strtolower

        $name = strtolower($details["name"]);
        if (count($details)) {
            foreach ($whitelist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return true;
                    }
                }
            }
            foreach ($blacklist as $term) {
                if (strlen($term) > 3 && trim($term)) {
                    if (stristr($name, $term) or stristr($artist, $term)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
if (!checkBlacklist($details)) {
    json_response(['success' => false, 'reason' => "That song matches the blacklist in this room."]);
}
if (count($details)) {
    $details['success'] = true;
    json_response($details);
}
$response = $video->responseArray();
if (isset($response['error'])) {
    json_response(['success' => false, 'message' => $response['error']['message']]);
}
开发者ID:williamtdr,项目名称:totem-api,代码行数:31,代码来源:getSongInfo.php


示例15: time

<?php

require_once './db.php';
$expire = time() - 3600;
setcookie('user[name]', '', $expire, '/');
setcookie('user[userid]', '', $expire, '/');
setcookie('user[nick]', '', $expire, '/');
setcookie('user[email]', '', $expire, '/');
unset($_COOKIE['user']);
echo json_response('success', null, null);
开发者ID:potch,项目名称:spenses,代码行数:10,代码来源:logout.php


示例16: json_response

function json_response($code, array $data, array $errors = [])
{
    if ($errors) {
        $data['errors'] = $errors;
    }
    http_response_code($code);
    header('Access-Control-Allow-Origin: *');
    header('Content-Type: application/json');
    echo json_encode($data);
    exit;
}
// Emulate a failure on 1/5 of the time
if (time() % 5 == 0) {
    json_response(400, [], ['Random failure emulation', rand(), rand(), rand()]);
}
// Emulate backend routes
switch (trim($_SERVER['QUERY_STRING'], '/')) {
    default:
        json_response(404, [], ['Page Not found']);
    case 'save':
        json_response(200, []);
    case 'getMask':
        json_response(200, [[0, 1, 2]]);
    case 'stats':
        $request = json_decode($_POST['data']);
        $response = ['prob_total' => rand(0, 100), 'groups' => []];
        foreach ($request->groups as $key => $notUsed) {
            $response['groups'][] = (object) ['pN' => rand(0, 100), 'pQ' => rand(0, 100), 'p' => rand(0, 100), 'rN' => rand(0, 100), 'rQ' => rand(0, 100), 'r' => rand(0, 100), 'cada' => rand(0, 1000)];
        }
        json_response(200, $response);
}
开发者ID:nerea91,项目名称:vue,代码行数:31,代码来源:api.php


示例17: array

        $out = array('name' => $_FILES['attach']['name'], 'size' => $_FILES['attach']['size'], 'type' => $_FILES['attach']['type'], 'error' => strip_tags($msg));
    }
    $res = array('attach' => array($out));
} elseif (isset($_REQUEST['_session'])) {
    if ($MSO->data['session']['session_id'] != $_REQUEST['_session']) {
        $res = array('error' => 'Истекла сессия пользователя!');
        json_response($res);
        die;
    }
    if (!touch(getinfo('uploads_dir') . $folder . '/' . $MSO->data['session']['session_id'] . '.sessid')) {
        $res = array('error' => 'Не получилось обновить время маркера сессии!');
        // На данный момент в плагине можно игнорировать.
        json_response($res);
        die;
    }
    $res = array('success' => true);
    //require( getinfo('plugins_dir').basename(dirname(__FILE__)).'clean.php' ); # чистка мусора
}
json_response($res);
die;
function json_response($resp)
{
    header('Content-type: application/json');
    header('Pragma: no-cache');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Content-Disposition: inline; filename="attach.json"');
    header('X-Content-Type-Options: nosniff');
    // Prevent Internet Explorer from MIME-sniffing the content-type:
    echo json_encode($resp);
}
# End file
开发者ID:wave-maxsite,项目名称:plugin-upload_editor,代码行数:31,代码来源:upload-ajax.php


示例18: function

<?php

if (!defined('SH_API_DIR')) {
    exit;
}
$app->get('/posts', function () use($app) {
    $postsObj = new Models\Posts();
    $posts = $postsObj->getAll();
    json_response($posts);
});
开发者ID:Ryan4021,项目名称:wp-as-a-backend-docker-compose,代码行数:10,代码来源:posts.routes.php


示例19: trigger_json_response

function trigger_json_response($code, $message)
{
    $error = array("code" => $code, "message" => $message);
    $response = json_encode($error, JSON_PRETTY_PRINT);
    json_response($response);
}
开发者ID:PatrickMurray,项目名称:AutomataFiddle,代码行数:6,代码来源:index.php


示例20: json_success

 /**
  * json 成功 响应
  *
  * @param $return
  */
 function json_success($return)
 {
     json_response($return);
 }
开发者ID:ptphp,项目名称:ptphp,代码行数:9,代码来源:HttpResponse.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP json_return函数代码示例发布时间:2022-05-15
下一篇:
PHP json_reply函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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