本文整理汇总了PHP中json_response函数的典型用法代码示例。如果您正苦于以下问题:PHP json_response函数的具体用法?PHP json_response怎么用?PHP json_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了json_response函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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'));
}
示例4: json_success
function json_success($result, $id)
{
$object = new stdClass();
$object->error = null;
$object->result = $result;
$object->id = $id;
json_response($object);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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');
}
示例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'));
}
示例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);
}
});
示例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'));
}
示例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);
}
示例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' => '删除事件成功'));
}
示例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']]);
}
示例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);