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开发者_如何学JAVA() {
$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?
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:
- Use a library, for example the PHP-SDK and ensure you autoload it, this will ensure that the access_token isn't lost.
- 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.
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
.
精彩评论