Sujeet
Sujeet

Reputation: 1800

Can't redirect inside canvas, CodeIgniter

I am using canvas for application development and the CodeIgniter framework.

I have a link in a view, <a href='http://example.com/index.php/module/controller/action'>click here</a> and I have a controller as:

public function index() {
    $user_profile = $this->facebook->api('/sujeet216');
    $token        = $this->session->userdata('token');

    $response     = $this->fb_model->checkUser($token);
    if ($response->num_rows <= 0) {
        if($this->fb_model->insertUser($user_profile,$token)) {
            $this->load->view('intro',$user_profile);
        }
    }
    else {
        $this->load->view('index',$user_profile);
    }
}

public function intro2() {
    $this->load->view('intro2');
}

Whenever I click a link, it redirects to the index controller. How do I load intro2 page from the second function?

Upvotes: 0

Views: 684

Answers (2)

Jorge Guberte
Jorge Guberte

Reputation: 11054

If you're not routing the URL, index.php/module/controller/action goes to index.php/controller/method/parameter. Try redirecting to index.php/controller/intro2.

Upvotes: 1

Ben
Ben

Reputation: 422

It's possible that the app is trying to authenticate and Facebook redirects the app back to the callback URL that you have set. You have two options to combat this:

  1. Use a library, for example the PHP-SDK and ensure you autoload it, this will ensure that the access_token isn't lost.
  2. Ensure that the API is being called and the access_token is being passed from each controller.

I'd recommend going for option number 1 as it gives you much more flexability in relation to using the API once the user has authenticated against Facebook.

Upvotes: 1

Related Questions