public function login_get (){
$this->load->helper ( 'auth' ); $redirectUrl = $this->input->cookie ( 'inapp_redirect', TRUE );
$redirectUrl = empty ( $redirectUrl ) ? '/index' : $redirectUrl; // 判斷是否已登入
if ( $this->input->cookie ( 'inapp_auth', TRUE ) ) {
delete_cookie ( 'inapp_redirect' );
header ( 'Location: ' . $redirectUrl );
exit;
} $user = $this->facebook->getUser ();
if ( $user ) { // FB 己登入
// 删除 redirect cookie
delete_cookie ( 'inapp_redirect' ); // 取得相對應的平台 uid
$params = array();
$params[ 'fbid' ] = $user;
$sp = 'CALL Member_SP_GetMemberRegInfoByFbid(?,@rtn)';
$member = $this->inapp->_query_sp ( $sp, $params, $error_no, 'row' ); //增加禁權的攔截
$status = $member[ 'status' ];
$checkStatus = $this->checkAccessBarred ( $status );
if ( ! $checkStatus )
exit (); // 存在則寫 cookie
if ( $error_no == _SUCCESS_ ) {
// 登入 Log
$params = array();
$params[ 'uid' ] = $member[ 'uid' ];
$params[ 'appid' ] = 1000000;
$sp = 'CALL App_SP_SetAppDailyLoginLog_v2(?,?,@rtn)';
$this->inapp->_query_sp ( $sp, $params, $error_no, 'row' ); //会员积分登录时间
$this->memberBat ( $member[ 'uid' ] ); //记录登陆信息
$this->member_model->addAdminLoginLog ( $member[ 'uid' ], 1, $params[ 'appid' ] ); // 取得授權
$params = array();
$params[ 'uid' ] = $member[ 'uid' ];
$params[ 'appid' ] = 1000000;
$sp = 'CALL App_SP_SetUserApp(?,?,@rtn)';
$this->inapp->_query_sp ( $sp, $params, $error_no, 'row' ); // 產生 auth
$auth = $this->_genAuth ( authHelper_genUUID ( $member, $this->config->item ( 'inappKey' ) ) );
$this->_setAuth ( $auth );
header ( 'Location: ' . $redirectUrl );
exit;
} // 不存在則取得 FB 相關個人資料
$fbuser_profile = $this->facebook->api ( '/me' ); // 寫入 Member DB
$params = array();
$params[ 'fbid' ] = $fbuser_profile[ 'id' ];
$params[ 'name' ] = empty ( $fbuser_profile[ 'name' ] ) ? '' : $fbuser_profile[ 'name' ];
$params[ 'link' ] = empty ( $fbuser_profile[ 'link' ] ) ? '' : $fbuser_profile[ 'link' ];
$params[ 'birthday' ] = empty ( $fbuser_profile[ 'birthday' ] ) ? '' : $fbuser_profile[ 'birthday' ];
$params[ 'gender' ] = empty ( $fbuser_profile[ 'gender' ] ) ? '' : $fbuser_profile[ 'gender' ];
$params[ 'email' ] = empty ( $fbuser_profile[ 'email' ] ) ? '' : $fbuser_profile[ 'email' ];
$params[ 'ip' ] = $_SERVER[ "REMOTE_ADDR" ]; $sp = 'CALL Member_SP_Register(?,?,?,?,?,?,?,@rtn)';
$member = $this->inapp->_query_sp ( $sp, $params, $error_no, 'row' ); // 註冊成功
if ( $error_no == _SUCCESS_ ) {
// 登入 Log
$params = array();
$params[ 'uid' ] = $member[ 'uid' ];
$params[ 'appid' ] = 1000000;
$sp = 'CALL App_SP_SetAppDailyLoginLog_v2(?,?,@rtn)';
$this->inapp->_query_sp ( $sp, $params, $error_no, 'row' ); //会员积分登录时间
$this->memberBat ( $member[ 'uid' ] ); //记录登陆信息
$this->load->model ( 'member_model' );
$this->member_model->addAdminLoginLog ( $member[ 'uid' ], 1, $params[ 'appid' ] ); // 取得授權
$params = array();
$params[ 'uid' ] = $member[ 'uid' ];
$params[ 'appid' ] = 1000000;
$sp = 'CALL App_SP_SetUserApp(?,?,@rtn)';
$this->inapp->_query_sp ( $sp, $params, $error_no, 'row' ); // 產生 auth
$auth = $this->_genAuth ( authHelper_genUUID ( $member, $this->config->item ( 'inappKey' ) ) );
} header ( 'Location: ' . $redirectUrl );
} else { // FB 未登入
$url = $this->facebook->getLoginUrl ( array('scope' => 'publish_stream, user_photos, email, user_birthday, user_online_presence', 'req_perms' => 5, 'fbconnect' => 0) );
header ( 'Location: ' . $url );
}
}

INAPP登陆调用的FB接口的更多相关文章

  1. 调用支付宝第三方接口(沙箱环境) SpringMVC+Maven

    一.蚂蚁金服开放平台的操作 网址:https://open.alipay.com/platform/home.htm 支付宝扫码登陆

  2. 在php中调用以及编写接口(转)

    如: http://localhost/openUser.php?act=get_user_list&type=json 在这里openUser.php相当于一个接口,其中get_user_l ...

  3. python接口自动化(三十五)-封装与调用--流程类接口关联(详解)

    简介 流程相关的接口,主要用 session 关联,如果写成函数(如上篇),s 参数每个函数都要带,每个函数多个参数,这时候封装成类会更方便.在这里我们还是以博客园为例,带着小伙伴们实践一下. 接口封 ...

  4. 如何请求一个需要登陆才能访问的接口(基于cookie)---apipost

    在后台在开发.调试接口时,常常会遇到需要登陆才能请求的接口. 比如:获取登陆用户的收藏列表,此时,我们就需要模拟登陆状态进行接口调试了.如图: 今天,我们讲解利用ApiPost的环境变量,解决这种需要 ...

  5. java调用CXF WebService接口的两种方式

    通过http://localhost:7002/card/services/HelloWorld?wsdl访问到xml如下,说明接口写对了. 2.静态调用 // 创建WebService客户端代理工厂 ...

  6. java获取https网站证书,附带调用https:webservice接口

    一.java 获取https网站证书: 1.创建一个java工程,新建InstallCert类,将以下代码复制进去 package com; import java.io.BufferedReader ...

  7. asp.net mvc 如何调用微信jssdk接口:分享到微信朋友(圈)| 分享到qq空间

    如何在asp.net mvc 项目里, 调用微信jssdk接口,现实功能: 分享到微信朋友(圈)| 分享到qq空间 1 创建一个Action,准备一些数据,初始化数据(签名): /// <sum ...

  8. 关于微信网页调用js-sdk相关接口注意事项目(一级域名与二级域名互相干扰!!!)

    不知道有没有网友遇到过同一个web应用用不同的域名(一级或二级域名)在两个公众号中调用JSSDK相关接口实现功能, 这种做法本来没有问题,问题在于用二级域名(同属一级域名下的二级域名)绑定另一个web ...

  9. JS调用腾讯接口获取天气

    想做个直接通过JS获取某个城市的天气.本来想通过直接调用中国气象网的接口: http://www.weather.com.cn/weather/101070201.shtml,但是跨域问题一直无法解决 ...

随机推荐

  1. 【14】PNG,GIF,JPG的区别及如何选

    [14]PNG,GIF,JPG的区别及如何选 GIF: 8位像素,256色 无损压缩 支持简单动画 支持boolean透明 适合简单动画 JPEG: 颜色限于256 有损压缩 可控制压缩质量 不支持透 ...

  2. 向php数组添加元素的方法哪种更高效

    $arr = array(); // 第一种 array_push($arr, 'test'); // 第二种 $arr[] = 'test'; 参考PHP官方文档:http://php.net/ma ...

  3. PHP “引号兄弟”

    PHP的string最大可以达到2GB,不过很少会用到这么大的字符串. 单引号: 定义一个字符串最简单的方式是使用单引号,而在单引号字符串中要想表达一个单引号,需要在她的前面加个反斜线(\)来进行转义 ...

  4. Leetcode 330.按要求补齐数组

    按要求补齐数组 给定一个已排序的正整数数组 nums,和一个正整数 n .从 [1, n] 区间内选取任意个数字补充到 nums 中,使得 [1, n] 区间内的任何数字都可以用 nums 中某几个数 ...

  5. php删除

    <?php$id = $_GET['id'];$db= new Mysqli("localhost","root","root",&q ...

  6. 两周多学完Java 23种设计模式

       最近两周任务不是很繁重,对于一个刚入职4个月的菜鸟来说,学习设计模式并灵活使用简直天方夜谭:但是当我询问我导师需要学点啥的时候?“<Java设计模式>,这个必须要学”,一句简单粗略的 ...

  7. HDU 3001 Travelling ——状压DP

    [题目分析] 赤裸裸的状压DP. 每个点可以经过两次,问经过所有点的最短路径. 然后写了一发四进制(真是好写) 然后就MLE了. 懒得写hash了. 改成三进制,顺利A掉,时间垫底. [代码] #in ...

  8. Numpy 花式索引

    记住:花式索引跟切片不一样,它总是将数据复制到新数组中. 一 给定一个列表,返回索引为1,3,4,5,6的数组 2 针对二维数组 需要注意的一点是,对于花式索引.对照下后面的两种方式,查询结果的不同.

  9. day02-菜单处理

    解决力度到按钮的级别 ----------------------------------------------------------------------------------------- ...

  10. polya burnside 专题

    polya题目:uva 11077 Find the Permutationsuva 10294 Arif in DhakaLA 3641 Leonardo's Notebookuva 11077 F ...