Yii Framework Forum: Yii Bypass Behaviour Request - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Yii Bypass Behaviour Request How can i call controller action without login or by passing Behaviour Rate Topic: -----

#1 User is offline   Kalpesh Desai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-November 14

Posted 09 April 2015 - 07:46 AM

Hello Every One

I have created Behaviour for forcing Login Request

My Behaviour code

<?php
class ApplicationBehavior extends CBehavior
{      
        private $_owner;
        public function events() 
        {
            return  array('onBeginRequest'=>'denyEverything',);
        }
        
        public function denyEverything()
       {
                $owner=$this->getOwner();
                if($owner->user->getIsGuest())
                   $owner->catchAllRequest=array("user/login");
       }
}
?>


Now I want to call Api That is controller Action like
example.com/site/api but its require login for me

how can i overcome this situation??????

i want use this only for Api call(Request from Mobile App).
0

#2 User is offline   Kalpesh Desai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-November 14

Posted 09 April 2015 - 10:47 PM

hello
My controller Action Like

public function actionApi()
	{
		$arry=array('myname'=>'My Name Here','Phone'=>'Phone No Here');
		echo json_encode($arry);
	}

is there any way to call this action without login
0

#3 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 247
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 10 April 2015 - 03:01 AM

Follow this tutorial - http://www.yiiframew...sing-cbehavior/
Thanks & regards,

ROHIT SUTHAR
Mumbai(India)

Follow me - @rohisuthar

yii.at

If you found your solutions.... Don't hesitate to click on '+1' button
0

#4 User is offline   Kalpesh Desai 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-November 14

Posted 11 April 2015 - 07:00 AM

Thank you for Your Reply...

I have read and its working fine but it is used for some specific Url... isn't it??

How can i solve for every controller action for api request

In One controller there were many action and system has many controller so array and param value is became large in your solution so is there any alternate solution???
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users