Facebook在本地主机开发 [英] Facebook development in localhost

查看:125
本文介绍了Facebook在本地主机开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是否有任何方法可以在本地主机中开发Facebook应用程序。

Just wanted to know if there is any way I could develop Facebook applications in localhost.

推荐答案

编辑:2-15-2012这是如何为本地主机网站使用FB身份验证。 >

2-15-2012 This is how to use FB authentication for a localhost website.

我发现设置第二个Facebook应用程序更具扩展性和便利性。如果我正在构建MyApp,那么我会再做一个名为MyApp-dev的第二个。

I find it more scalable and convenient to set up a second Facebook app. If I'm building MyApp, then I'll make a second one called MyApp-dev.


  • https://developers.facebook.com/apps

  • (新的2/15/2012)单击选择您的应用程序与Facebook集成
    下的网站复选框(在最近的Facebook版本中,您可以在设置>基本>添加平台 - 然后选择网站下找到此项。

  • 设置站点URL 字段(不是应用程序域名字段 )到 http://www.localhost:3000 (这个地址是Ruby on Rails,更改为需要)

  • Create a new app at https://developers.facebook.com/apps
  • (New 2/15/2012) Click the Website checkbox under 'Select how your application integrates with Facebook' (In the recent Facebook version you can find this under Settings > Basic > Add Platform - Then select website)
  • Set the Site URL field (NOT the App Domains field) to http://www.localhost:3000 (this address is for Ruby on Rails, change as needed)


  • 在应用程序初始化程序中,放入代码以检测环境


    • 示例轨道s 3代码

    • In your application initializer, put in code to detect the environment
      • Sample Rails 3 code
      
      if Rails.env == 'development' || Rails.env == 'test'
        Rails.application.config.middleware.use OmniAuth::Builder do
          provider :facebook, 'DEV_APP_ID', 'DEV_APP_SECRET'
        end
      else
        # Production
        Rails.application.config.middleware.use OmniAuth::Builder do
          provider :facebook, 'PRODUCTION_APP_ID', 'PRODUCTION_APP_SECRET'
        end
      end
      


    • 因为一旦设置好,同事和其他机器就没有额外的设置。

      I prefer this method because once it's set up, coworkers and other machines don't have additional setup.

      这篇关于Facebook在本地主机开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆