【问题标题】:Joomla: passing array of items in REST get methodJoomla:在 REST get 方法中传递项目数组
【发布时间】:2014-11-26 21:46:03
【问题描述】:

我正在为移动应用程序编写一个 RESTFul 服务。我的 REST 网址如下:

/index.php/jbackend/get/recipe/list_recipe?id=3,4,5

其中,3,4,5 是 recipeid。

在 joomla 代码中,我要解析以下内容:

    $ids = $app->input->get('id', array(), 'ARRAY');
    $i=0;
    foreach($ids as $id){
        $i+=1;
        $response['array'.$i] = $id;
    }

我得到了答案

{"array1":"4,5,6"}

我期待

{"status":"ok","array1":"4","array2":"5","array3":"6"}

要得到上述,需要改变什么?

【问题讨论】:

    标签: php joomla3.0 restful-url


    【解决方案1】:

    我找到了一种方法,如下所示:

    传递参数为

    1. 获取

      /index.php/jbackend/get/recipe/list_recipe?id[]=3&id[]=4&id[]=5

    2. 发帖

      /index.php/jbackend/get/recipe/list_recipe 并将参数作为后置参数。

    希望这对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-10
      • 2012-02-25
      • 1970-01-01
      相关资源
      最近更新 更多