开发者

How to continue developing locally, on a Facebook based website that's already online?

开发者 https://www.devze.com 2023-02-12 20:10 出处:网络
I have a site that uses, exclusively, Facebook authentication as it\'s membership system. In the Facebook app settings the callback url is set to the开发者_运维问答 site\'s domain.

I have a site that uses, exclusively, Facebook authentication as it's membership system. In the Facebook app settings the callback url is set to the开发者_运维问答 site's domain.

I'd like to continue development of the site, locally... while keeping the site live as well. However, since the callback url is the site's live domain name and not the localhost address, the Facebook authentication parts fail.

Is it possible to have both a localhost and a domain callback url active? If not, what's standard practice in continuing local development of a site that is already live?


Assuming you use ASP. But will work for any language.

You can create another application in facebook with http://localhost as the domain name. Store the appid and secret in the web.config file separately.

Then in the code behind of your master page, check for the Request.ServerVariables("HTTP_HOST") and if it is localhost, use the appropriate settings from the web.config file.

If Request.ServerVariables("HTTP_HOST").StartsWith("localhost") Then
    FBAppID = System.Configuration.ConfigurationManager.AppSettings.Item("FBAppIDLocal")
Else
    FBAppID = System.Configuration.ConfigurationManager.AppSettings.Item("FBAppID")
End If


You can specify the callback url when you request your access token:

https://www.facebook.com/dialog/oauth?
 client_id=YOUR_APP_ID&redirect_uri=YOUR_URL

This should overide the other callback path. See here.


You could create a new app (copy code), like a new branch, and develop it locally, and when its done, then upload it to the online version (like a merge).

To develop locally:

Facebook-->Settings-->Basic, write "localhost" in the "App Domains" field, then click on "+Add Platform" choose "Web Site".

Then in the "Site Url" field write your localhost url (e.g.: http://localhost:1337/something).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号