• <bdo id='lqxHG'></bdo><ul id='lqxHG'></ul>

      <legend id='lqxHG'><style id='lqxHG'><dir id='lqxHG'><q id='lqxHG'></q></dir></style></legend>
      <tfoot id='lqxHG'></tfoot>
      1. <small id='lqxHG'></small><noframes id='lqxHG'>

        <i id='lqxHG'><tr id='lqxHG'><dt id='lqxHG'><q id='lqxHG'><span id='lqxHG'><b id='lqxHG'><form id='lqxHG'><ins id='lqxHG'></ins><ul id='lqxHG'></ul><sub id='lqxHG'></sub></form><legend id='lqxHG'></legend><bdo id='lqxHG'><pre id='lqxHG'><center id='lqxHG'></center></pre></bdo></b><th id='lqxHG'></th></span></q></dt></tr></i><div id='lqxHG'><tfoot id='lqxHG'></tfoot><dl id='lqxHG'><fieldset id='lqxHG'></fieldset></dl></div>
      2. redirect_uri URL 必须是绝对 Facebook 登录 PHP SDK

        The redirect_uri URL must be absolute Facebook login PHP SDK(redirect_uri URL 必须是绝对 Facebook 登录 PHP SDK)
      3. <i id='PbwpU'><tr id='PbwpU'><dt id='PbwpU'><q id='PbwpU'><span id='PbwpU'><b id='PbwpU'><form id='PbwpU'><ins id='PbwpU'></ins><ul id='PbwpU'></ul><sub id='PbwpU'></sub></form><legend id='PbwpU'></legend><bdo id='PbwpU'><pre id='PbwpU'><center id='PbwpU'></center></pre></bdo></b><th id='PbwpU'></th></span></q></dt></tr></i><div id='PbwpU'><tfoot id='PbwpU'></tfoot><dl id='PbwpU'><fieldset id='PbwpU'></fieldset></dl></div>
        <legend id='PbwpU'><style id='PbwpU'><dir id='PbwpU'><q id='PbwpU'></q></dir></style></legend>

              <tfoot id='PbwpU'></tfoot>
              • <small id='PbwpU'></small><noframes id='PbwpU'>

                  <bdo id='PbwpU'></bdo><ul id='PbwpU'></ul>
                    <tbody id='PbwpU'></tbody>
                  本文介绍了redirect_uri URL 必须是绝对 Facebook 登录 PHP SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 codeigniter 的项目中实现 facebook 登录.

                  I am trying to implement the facebook login in my project in codeigniter.

                  我正在使用 php sdk.

                  I am using the php sdk.

                  当我点击登录按钮时,它给了我一个错误:

                  When I click on the login button, it gives me an error:

                  The redirect_uri URL must be absolute
                  

                  有什么问题,我该如何解决?

                  What is the problem and how do I fix it?

                  这里是view/home.php的内容:

                   <?php if(!$fb_data['me']): ?>
                    Please login with your FB account: 
                    <a href="<?php echo $fb_data['loginUrl']; ?>">login</a>
                    <?php else: ?>
                    <img src="https://graph.facebook.com/<?php 
                      echo $fb_data['uid']; ?>/picture" alt="" class="pic" />
                    <p>Hi <?php echo $fb_data['me']['name']; ?>,<br />
                      <a href="<?php 
                      echo site_url('welcome/topsecret'); ?>">
                      You can access the top secret page</a> or 
                      <a href="<?php echo $fb_data['logoutUrl']; ?>">logout</a> </p>
                    <?php endif; ?>
                  

                  这里的内容是:controler/home.php

                  class Home extends CI_Controller {
                  
                     function __construct()
                      {
                          parent::__construct();
                  
                          $this->load->model('Facebook_model');
                      }
                  
                      function index(){
                          $this->load->model("Concertos_model");
                          $data['banners'] = $this->Concertos_model->get_banner_data();
                  
                  
                         $fb_data = $this->session->userdata('fb_data'); // This array contains all the user FB information
                  
                          $data = array(
                                      'fb_data' => $fb_data,
                                      );
                  
                          $this->load->view('home', $data);   
                  
                      }
                  
                      function topsecret()
                      {
                          $fb_data = $this->session->userdata('fb_data');
                  
                          if((!$fb_data['uid']) or (!$fb_data['me']))
                          {
                              redirect('home');
                          }
                          else
                          {
                              $data = array(
                                          'fb_data' => $fb_data,
                                          );
                  
                              $this->load->view('home', $data);
                          }
                      }
                  
                  }
                  

                  内容:model/Facebook_model.php:

                  <?php
                  class Facebook_model extends CI_Model {
                  
                      public function __construct()
                      {
                          parent::__construct();
                  
                          $config = array(
                                          'appId'  => 'xxxxxxxxxxxxxxxxxxx',
                                          'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
                                          'fileUpload' => true, // Indicates if the CURL based @ syntax for file uploads is enabled.
                                          );
                  
                          $this->load->library('Facebook', $config);
                  
                          $user = $this->facebook->getUser();
                  
                          // We may or may not have this data based on whether the user is logged in.
                          //
                          // If we have a $user id here, it means we know the user is logged into
                          // Facebook, but we don't know if the access token is valid. An access
                          // token is invalid if the user logged out of Facebook.
                          $profile = null;
                          if($user)
                          {
                              try {
                                  // Proceed knowing you have a logged in user who's authenticated.
                                  $profile = $this->facebook->api('/me?fields=id,name,link,email');
                              } catch (FacebookApiException $e) {
                                  error_log($e);
                                  $user = null;
                              }
                          }
                  
                          $fb_data = array(
                                          'me' => $profile,
                                          'uid' => $user,
                                          'loginUrl' => $this->facebook->getLoginUrl(
                                              array(
                                                  'scope' => 'email,user_birthday,publish_stream', // app permissions
                                                  'redirect_uri' => 'home' // URL where you want to redirect your users after a successful login
                                              )
                                          ),
                                          'logoutUrl' => $this->facebook->getLogoutUrl(),
                                      );
                  
                          $this->session->set_userdata('fb_data', $fb_data);
                      }
                  }
                  

                  为什么 facebook 会返回该消息,我该如何解决?

                  Why does facebook return that message and how do I fix it?

                  推荐答案

                  'redirect_uri' => 'home' // URL where you want to redirect your users after a successful login
                  

                  您必须提供完整的 URL(从 http:// 开始),而不是 CI 页面别名.改用 site_url('home')

                  You have to provide full URL (starting from http://), not CI page alias. Use site_url('home') instead

                  这篇关于redirect_uri URL 必须是绝对 Facebook 登录 PHP SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='a2lce'></small><noframes id='a2lce'>

                      <bdo id='a2lce'></bdo><ul id='a2lce'></ul>

                            <tbody id='a2lce'></tbody>
                          • <legend id='a2lce'><style id='a2lce'><dir id='a2lce'><q id='a2lce'></q></dir></style></legend>

                            <i id='a2lce'><tr id='a2lce'><dt id='a2lce'><q id='a2lce'><span id='a2lce'><b id='a2lce'><form id='a2lce'><ins id='a2lce'></ins><ul id='a2lce'></ul><sub id='a2lce'></sub></form><legend id='a2lce'></legend><bdo id='a2lce'><pre id='a2lce'><center id='a2lce'></center></pre></bdo></b><th id='a2lce'></th></span></q></dt></tr></i><div id='a2lce'><tfoot id='a2lce'></tfoot><dl id='a2lce'><fieldset id='a2lce'></fieldset></dl></div>
                            <tfoot id='a2lce'></tfoot>