IT

로컬로 Facebook Connect를 테스트하는 방법

lottoking 2020. 5. 13. 08:17
반응형

로컬로 Facebook Connect를 테스트하는 방법


ASP .NET 및 Facebook Connect API를 사용합니다. 그러나 응용 프로그램을 실행하고 연결 버튼을 누르면 테스트 로컬 서버가 아닌 웹 사이트 ( http : // localhost : xxxx / test.aspx )로 돌아갑니다 . 따라서 Facebook을 로컬로 테스트하는 방법은 무엇입니까? 콜백 URL)?


당신이 알아낼 때 충분히 간단합니다.

/etc/hosts(유닉스) 또는을 엽니 다 C:\WINDOWS\system32\drivers\etc\hosts.

도메인이 foo.com 인 경우 다음 줄을 추가하십시오.

127.0.0.1    local.foo.com

테스트 할 때 local.foo.com브라우저에서 열면 작동합니다.


www.facebook.com/developers/ 에서 앱을 편집 하고 "사이트 URL"을 "http : // localhost / myapppath"로 설정하십시오.

완료되면 다시 변경하십시오.


https://developers.facebook.com/apps 에서 테스트 응용 프로그램 (개발 환경 전용)을 만들고 localhost : [port] 설정으로 Website with Facebook Login속성을 설정하는 것이 좋습니다. 이 옵션은 호스트를 변경할 필요없이 잘 작동합니다. 시작한 후에 appId 를 프로덕션 앱으로 다시 변경 해야합니다.


편집 -최신 fb 버전에서는 settings아래에 있습니다.여기에 이미지 설명을 입력하십시오


Facebook에는 테스트 버전 기능이 추가되었습니다.

먼저 애플리케이션의 테스트 버전을 추가 하십시오. 테스트 앱 작성

테스트 앱 만들기

그런 다음 Website 아래 에서 사이트 URL 을 " http : // localhost "로 변경하고 변경 사항 저장을 누르 십시오.

여기에 이미지 설명을 입력하십시오

That's all, but be careful: App ID and App Secret keys are different for the application and its test versions!


You don't have to do anything difficult!

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

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

This will allow you to test your facebook plugins locally.


Facebook seemingly randomly disables the ability to set localhost as a domain on your facebook app. I found the easiest work around was to tunnel my localhost to the web. This can be done for free using http://progrium.com/localtunnel/ or with a custom url (easier since you don't have to change url everytime in facebook) https://showoff.io


I couldn't use the other solutions... What worked for me was installing LocalTunnel.net (https://github.com/danielrmz/localtunnel-net-client), and then using the resulting url on Facebook.


Looks like FB just changed the app dev page again and added a feature called "Server IP Whitelist".

  1. Go to your app and Select Settings -> Advanced Tab
  2. Get your public IP (google will tell you if you google "Whats My IP")
  3. 서버 IP 화이트리스트에 퍼블릭 IP를 추가하고 하단에서 변경 사항 저장을 클릭하십시오.

캔버스 페이지로 이동합니다. 브라우저에서 볼 수 있습니다. 주소 표시 줄 텍스트를 복사하십시오. 이제 페이스 북 앱으로 이동하여 설정 수정으로 이동

웹 사이트, 사이트 URL에 해당 주소 붙여 넣기

페이스 북 통합에서 캔버스 URL에 해당 주소를 다시 붙여 넣으십시오.

또한 캔버스 URL 또는 리디렉션 URL이 필요한 곳마다 동일한 코드를 사용하십시오.

도움이 되길 바랍니다 ..


2 개의 앱을 만들고

에서 /initializers/env_variables.rb

if Rails.env == 'development'
    ENV['FB_APP_ID'] = "HERE"
    ENV["FB_SECRET"] = "HERE"
else
    ENV['FB_APP_ID'] = "HERE"
    ENV["FB_SECRET"] = "HERE"
end

참고 URL : https://stackoverflow.com/questions/2459728/how-to-test-facebook-connect-locally

반응형