是否有可能从yii应用程序登录蛋糕PHP应用程序?

时间:2015-06-11 12:52:28

标签: php cakephp curl yii

我正在尝试使用cake php同步yii应用程序。主要动机是如果用户在一个应用程序中填写表单,则登录到两个系统。 yii应用程序在root上,而蛋糕php应用程序在文件夹中。因此网址是

表示yii http://192.168.1.31/Eb/
而对于蛋糕php,http://192.168.1.31/Eb/projectmanager/这些是本地的。

现在我已经使用curl在yii控制器中创建了一个函数,并在登录时调用它。

private function logintoprojectmanager($post)
    {
        $fields = array(
                        'User'=>array(
                        'email' => 'manoj@rudrainnovatives.com',
                        'password' => 'manoj@41@'

                            )
                        );
        $urltopost="http://192.168.1.31/Eb/projectmanager/login";               
        $fields_string = http_build_query($fields);             
        $ch = curl_init ($urltopost);
        curl_setopt ($ch, CURLOPT_POST, true);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, false);
        $returndata = curl_exec ($ch);
        curl_close ($ch);
        print_r($returndata); //display the reuslt*/
        die;
    }

和cake php应用程序中的登录功能是

public function login()
    {
        $this->__login();
        $this->render('login');
    }
private function __login()
    {
        $this->layout = 'default';

        if (AuthComponent::user())
            $this->redirect(array('controller' => 'projects', 'action' => 'index'));

        if ($this->request->is('post'))
        {
            $this->User->set($this->request->data);
            if ($this->Auth->login())
            {
                echo "logged in ";
                if ($this->request->data['User']['remember_me'] == 1)
                {
                    unset($this->request->data['User']['remember_me']);
                    $this->request->data['User']['password'] = $this->Auth->password($this->request->data['User']['password']);
                    $this->Cookie->write('cepp_pauth', $this->request->data['User'], true, '2 weeks');
                }

                if (!AppAuth::is(UserRoles::Admin) && AppConfig::read('System.maintenance') === true)
                {
                    $this->Session->setFlash(__('The system is in maintenance mode.'), Flash::Error);
                    $this->redirect($this->Auth->logout());
                }

                $this->Session->setFlash(__('You successfully logged in.'), Flash::Success);
                if (!empty($this->request->params['admin']))
                    $this->redirect(array('controller' => 'projects', 'action' => 'index'));
                else
                    $this->redirect($this->Auth->redirectUrl());
            } else
            {
                echo "incorrect credentials";
                unset($this->request->data['User']['password']);
                $this->Session->setFlash(__('The username/password you provided were incorrect.'));
            }
        }
        $this->set('title_for_layout', __('Login'));
    }

我正在收到“登录”的卷曲回复。但是,当我打开蛋糕php应用程序时,它会将我重定向到登录表单。哪里我错了?

任何帮助都会得到满足。谢谢

0 个答案:

没有答案