Unable to read 2nd paramater passed in Zend_Rest_Client

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Unable to read 2nd paramater passed in Zend_Rest_Client

What i am trying to do is pass $rest->apikey to my Zend_Rest_Server.
The empAction creates the array needed by my Zend_Rest_Server. But in getByShortname($id,$apikey), I cannot read the $apikey. They query to check the API key does not return any results.

    $rest = new Zend_Rest_Client('http://localhsot/api/emp');
    $result = $rest->get();
    var_dump($result); //should work
    //For Emp method--> api/emp
    //... rest of code ...
    public function empAction()
        require_once 'EmprestServer.php';
        $params = $this->_getAllParams();
        $param_keys = array_keys($params);
        if($param_keys[0]=='id') {
            $request = array('method' => 'getById');
        } else if($param_keys[0]=='shortname') {
            $request = array('method' => 'getByShortname');
        foreach($param_keys AS $key) {
            $request[$key] = $filter_params[$key]; //need to filter key
            //need better checking
            if(!$request[$key]) {
                throw new Exception($request[$key].' contained invalid data.');
    I am able to generate this array using the code prior to this line...
        $request = array();
        $request['method']    = 'getByShortname';
        $request['shortname'] = 'wdelrosa';
        $request['apikey']    = '1234';
        $server = new Zend_Rest_Server();
    //... rest of code ...
    //The Class
    class EmprestServer
        public function getByShortname($shortname,$apikey)
            $emp = new Employee();
            $data = array();
            /** PROBLEM **/
            /** I can't access $apikey WHY? Any ideas? **/
            if(!$this->checkKey($apikey)) {
                throw new Exception('Key is invalid.');
            if(!$data = $emp->getEmployeeByShortname($shortname)) throw new Exception('Employee ID not found.');
            $data = $data->toArray();
            return $data;

UPDATE: this seems to work. I get a valid XML output with this


But if i use the Zend_Rest_Client above, the apikey is not read.