Thinkphp 3.2.3 rest 获取参数和url访问的问题

浏览:4200 发布日期:2015/05/26 分类:求助交流 关键字: Thinkphp3.2.3 rest
Thinkphp 3.2.3

传入interface_id = 1,获取的结果却是加了后缀的1.json

不传入任何参数却报错 非法操作:send.json
这是为什么,我哪里写错了?<?php

namespace Api\Controller;

class SmsController extends ApiController {
    protected $allowMethod    = array('get','post','put'); // REST允许的请求类型列表
    protected $allowType      = array('html','xml','json'); // REST允许请求的资源类型列表
    public function send_post_json(){
        $request['interface_id'] = I("interface_id");
        $request['content'] = I("content");
        $this->sendFun($request);
    }
    public function send_get_json(){
        $request['interface_id'] = I("interface_id");
        $request['content'] = I("content");
        $this->sendFun($request);
    }
    public function sendFun($request = array() , $type = "json"){
        $interface_id = $request['interface_id'];
        $content = $request['content'];
        $data = array();
        if(!$interface_id){
            $data['status'] = 0;
            $data ['request'] = U ( CONTROLLER_NAME . "/" . ACTION_NAME ) . "." . $type;
            $data ['error_code'] = "20001";
            $data ['error'] = "interface_id is null";
            $this->response ( $data, $type );
        }
        if(!$content){
            $data['status'] = 0;
            $data ['request'] = U ( CONTROLLER_NAME . "/" . ACTION_NAME ) . "." . $type;
            $data ['error_code'] = "20001";
            $data ['error'] = "content is null";
            $this->response ( $request, $type );
        }
    }

} 
<?php
namespace Api\Controller;

use Think\Controller\RestController;

class ApiController extends RestController{
}
配置文件    'URL_HTML_SUFFIX'       =>  '',  // URL伪静态后缀设置后缀配置为空的时候正常!
最佳答案
评论() 相关
后面还有条评论,点击查看>>