I’m developing a WordPress plugin and in the backend of the plugin the user needs to add their own Facebook App ID and Facebook Secret
I’m trying to figure out if there is a way of checking the user’s facebook App ID and Secret are correct and display some kind of success or failure message.
I can’t see any documentation on how this might be possible…I’m assuming I can do something after FB.init?
FB.init({
appId : '<?php echo get_option('hc_fb_appid') ?>', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
I was thinking of trying to use this:
FB.getLoginStatus(function(response)) {
// code goes here
});
to determine whether the FB app settings are valid. However, this function doesn’t run if invalid and I don’t know how to check if the function has run or not.
How about just trying to read one of the app attributes from the API that require an app access token …?
The combination of
app_id|app_secretworks as an app access token, so if you have both of these variables just concatenate them with a pipe symbol in the middle, and make an API request for an attribute that needs app access token – in response you will either get a value (might be an empty one, but who cares) – or an OAuth error message/exception saying that the access token used was not valid.https://developers.facebook.com/docs/reference/api/application/