我不会得到JSON的.我已经试过很多次了.我没有得到任何JSON.如果你知道其中哪些是错的,请让我知道.此网站URL JSON未发布.我试了很多次,但没有发布API:https://kalviaruvi.com/simpleshopping/api-firebase/get-categories.php?accesskey=90336

这个Get-Categories.php

     <?php
     header('Access-Control-Allow-Origin: *');
     header("Content-Type: application/json");
     header("Expires: 0");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    include_once('../includes/crud.php');
    $db = new Database();
    $db->connect();
    include_once('../includes/variables.php');
    include_once('../includes/custom-functions.php');
    $fn = new custom_functions;
    $config = $fn->get_configurations();
    $time_slot_config = $fn->time_slot_config();
    if (isset($config['system_timezone']) && isset($config['system_timezone_gmt'])) {
    date_default_timezone_set($config['system_timezone']);
    $db->sql("SET `time_zone` = '" . $config['system_timezone_gmt'] . "'");
    } else {
    date_default_timezone_set('Asia/Kolkata');
    $db->sql("SET `time_zone` = '+05:30'");
    }
    if (isset($_POST['accesskey'])) {
    $access_key_received = $db->escapeString($fn- 
 >xss_clean($_POST['accesskey']));
    if ($access_key_received == $access_key) {
        // get all category data from category table
        $sql_query = "SELECT * 
            FROM category 
            ORDER BY id ASC ";
        $db->sql($sql_query);
        $res = $db->getResult();
        if (!empty($res)) {
            for ($i = 0; $i < count($res); $i++) {
                $res[$i]['image'] = (!empty($res[$i]['image'])) ? DOMAIN_URL . '' . $res[$i]['image'] : '';
                $res[$i]['web_image'] = (!empty($res[$i]['web_image'])) ? DOMAIN_URL . '' . $res[$i]      ['web_image'] : '';
            }
            $tmp = [];
            foreach ($res as $r) {
                $r['childs'] = [];

                $db->sql("SELECT * FROM subcategory WHERE category_id = '" . $r['id'] . "' ORDER BY id   DESC");
                $childs = $db->getResult();
                if (!empty($childs)) {
                    for ($i = 0; $i < count($childs); $i++) {
                        $childs[$i]['image'] = (!empty($childs[$i]['image'])) ? DOMAIN_URL . '' . $childs[$i]['image'] : '';
                        $r['childs'][$childs[$i]['slug']] = (array)$childs[$i];
                    }
                }
                $tmp[] = $r;
            }
            $res = $tmp;
            $response['error'] = "false";
            $response['data'] = $res;
        } else {
            $response['error'] = "true";
            $response['message'] = "No data found!";
        }
        print_r(json_encode($response));
    } else {
        die('accesskey is incorrect.');
    }
     } else {
    die('accesskey is require.');
    }
    $db->disconnect();

此自定义功能

   <?php
//access key to access API
$access_key = "90336";

//google play url
$gplay_url = "https://play.google.com/store/apps/details?id=com.city.ecommerce";

// email configuration
$email_subject = "Notification of changes to account information!";
$change_message = "You have change your admin info such as email and or password.";
$reset_message = "Your new password is ";

//order notification configuration
$reservation_subject = "New Order Notification!";
$reservation_message = "There is new order, please check Admin Panel.";
$order_subject = "Order Confirm Notification!";
$order_message = "your order has been placed. we will reach to you very soon";

$register_subject = "Thank You for Registering with City-Ecommerce";
$register_message = "Thank You for Registering with City-Ecommerce. We Welcome you to best shopping experience for your family";
$process_subject = "Confirmation mail for you City-Ecommerce order no ";
$process_message = "Thank you for shopping at City-Ecommerce<br>
    The following items in your order will be shipped from our warehouse.<br>
    Once these items have been shipped, we will send you an email with the expected delivery date.<br>
    Order Details: <br>";
$shipped_subject = " Your City-Ecommerce Order has been shipped from here";
$shipped_message = "Thank you for your order on City-Ecommerce. Your Order No .";
                    
$delievered_subject = " Your City-Ecommerce order no.";
$delievered_message = "Thank you for your order on City-Ecommerce. Your Order No .";
//copyright
$copyright = "";

    ?>

如何获取JSON API URL.

推荐答案

如果希望从URL获取值,请在get-categories.php中使用$_GET而不是$_POST.

如果你想继续使用$_POST,你不能通过浏览器访问API,只需在URL末尾追加参数即可.

Php相关问答推荐

如何使用PHP停止foreach循环中的重复项?

照明\Support\Collection::Filter():参数#1($Callback)的类型必须为?可调用、已给定数组、已调用

WooCommerce管理订单列表自定义列不显示值

使用正则表达式搜索两个子字符串(没有重叠/共享字符)

在WooCommerce中设置带有国家/地区和年份前缀的顺序序号

PHP-带POST验证的for循环

Laravel Nova不使用数组键作为筛选器中的选项值

FlySystem v3:使用本地适配器时出现问题

HTTPPost请求在从php脚本调用时返回404,但在从node.js脚本调用时有效.终结点有效

如何在codeigniter中将order_by RAND与下面的代码一起使用

Mockery在模拟Redis连接时抛出错误:Mockery\Exception\BadMethodCallException

在 WooCommerce 订阅续订订单中设置送货方式

从 XAMPP 运行 shell 脚本时,意外标记(附近出现语法错误

为什么从一个页面到另一个页面都找不到 JQuery,因为它们使用相同的 twig 模板?

将自定义保存金额移至 Woocommerce 简单产品中的价格以下

提交仅包含活动详细信息选项卡表单的主表单

如何修复正则表达式以在换行符后查找非数值

在 laravel 中更新表单时如何在 Select 选项中保留旧值?

在 WooCommerce 结帐后更新用户元字段

如何通过路由传递变量