Facebook registration page - Invalid 'client_id' when not logged into Facebook

匿名 (未验证) 提交于 2019-12-03 08:59:04

问题:

I have made a Facebook registration form that works with custom fields and functions as I expect, EXCEPT when the user is not logged into facebook when they first visit the form.

In this situation the form does not render on screen and the following error appears:

Unable to load the registration form for this ID. You may have previously blocked this app on Facebook. Go to your Facebook privacy settings to unblock this app. (Error: Invalid 'client_id'.)

Now I know already that this has been discussed on the site but the solutions offered elsewhere don't work for me and I really want this to work based in the XFBML solution that facebook supports (a demo is here http://developers.facebook.com/docs/plugins/registration/)

If you logout of facebook you can visit a test of my code, taken directly from the facebook example and hardly modified here: https://www.askanutritionist.com/fb.html

By the way, yes sandbox is disabled in the facebook app settings as thats a common fix others on S.O. have suggested.

Thanks for your time. Note; I would have commented on other existing questions with this topic but stackoverflow won't let me (yet).

回答1:

Check that the app whose ID you're using isn't restricted demographically (e.g. by age or country) and that it isn't still in sandbox mode.

If it is restricted or in sandbox mode, users who aren't logged in and who meet the restrictions applied (or for sandbox mode, are admins of the app) can't see the existence of the app or its details until they log in.



回答2:

Just to confirm; I never actually fixed this properly. Instead I made a work around and was able to do a javascript check via the facebook sdk to see if the user was logged in or not when they first hit the page that has the facebook registration form.

I do an http redirect if they aren't logged in (or aren't authorised) and if they are logged in later in the page I call to init the facebook form.

window.fbAsyncInit = function() { FB.init({     appId      : xxxx, // App ID     channelUrl : 'http:///xxxxx/fbchannel.php',      status     : true, // check login status     cookie     : true, // enable cookies to allow the server to access the session     xfbml      : true  // parse XFBML });  // Additional initialization code here FB.getLoginStatus(function(response) {     if (response.status === 'connected') {         // all ok!         //var uid = response.authResponse.userID;         //var accessToken = response.authResponse.accessToken;     } else if (response.status === 'not_authorized') {         window.location.href="create_account_with_facebook?authorizefirst";     } else {         window.location.href="create_account_with_facebook?loginfirst";     } }); }; // Load the SDK Asynchronously (function(d){     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];     if (d.getElementById(id)) {return;}     js = d.createElement('script'); js.id = id; js.async = true;     js.src = "//connect.facebook.net/en_US/all.js";     ref.parentNode.insertBefore(js, ref);  }(document)); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!