donglue8180 2012-10-22 11:50
浏览 35
已采纳

使用Yii框架和facebook注册插件创建注册表单

I am using a facebook registration plugin to register users if they have a facebook account or using the default registration form if they don't have a fb account.

I have created the default registration form in yii framework storing data using model into database.

I have also written code to use facebook registration plugin using iframe.

The problem is that how to save the data in database filled in fb registration plugin form and what to mention in redirect-uri ?

  • 写回答

1条回答 默认 最新

  • dseslyh6662605 2012-10-22 14:34
    关注

    After facebook has authenticated the user, and given permission to your application, you can get the user data using the facebook sdk (either php or js) by calling the api method "/me".

    example using the php sdk:

    $user = $facebook->getUser();
    if ($user) {
      try {
        $user_profile = $facebook->api('/me');
        //Now using the the facebook data we create 'our' user
        $model = new User;
        $model->username = $user_profile['fullname'];
        //and so on..
        $model->save();
      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
    }
    

    more details in the oficial php sdk repo

    The return URL must point to your application's page, the one you configured when you created the application on facebook

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题
  • ¥15 有没有人能解决下这个问题吗,本人不会编程
  • ¥15 plotBAPC画图出错
  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗