我必须发布用户名、密钥和另一个参数才能将数据作为 JSONObject 获取并在 RecyclerView 中显示它们。我在 android 中使用 Volley Library,尝试了所有可能的方法,但没有一个有帮助。即使通过 Postman 进行测试似乎工作正常,并且当我发布这三个参数时我得到了数据,但我不知道我错过了什么安卓..
PHP代码:
<?php
require("db/Db.class.php");
if(isset($_POST['key']) && isset($_POST['username']) && isset($_POST['getMainCategory'])){
$db = new DB();
$username = $_POST['username'];
$key = $_POST['key'];
$query = $db->query("SELECT * FROM oc_api where `username` = '$username' and `key` = '$key' limit 1 ");
if(count($query) == 0){
$json = ["error don't have permittion"];
}else{
$catigory = $db->query("SELECT * FROM `oc_category_description`,oc_category WHERE oc_category_description.category_id = oc_category.category_id and oc_category.status = 1 and oc_category.parent_id = 0 and oc_category_description.language_id = 2");
$json = $catigory;
}
header('Content-Type: application/json');
echo json_encode($json);
return;
}
if(isset($_POST['key']) && isset($_POST['username']) && isset($_POST['getSlideShow'])){
$db = new DB();
$username = $_POST['username'];
$key = $_POST['key'];
$slideShowId = (int)$_POST['getSlideShow'];
$query = $db->query("SELECT * FROM oc_api where `username` = '$username' and `key` = '$key' limit 1 ");
if(count($query) == 0){
$json = ["error don't have permittion"];
}else{
$banderSlideShow = $db->query("SELECT * FROM `oc_banner_image` where `banner_id` = $slideShowId and language_id = 2");
$json = $banderSlideShow;
}
header('Content-Type: application/json');
echo json_encode($json);
return;
}
if(isset($_POST['key']) && isset($_POST['username']) && isset($_POST['getAllNews'])){
$db = new DB();
$username = $_POST['username'];
$key = $_POST['key'];
$query = $db->query("SELECT * FROM oc_api where `username` = '$username' and `key` = '$key' limit 1 ");
if(count($query) == 0){
$json = ["error don't have permittion"];
}
MMMHUHU
慕标5832272
慕哥6287543
相关分类