[Plugin: WPBook Lite] Generate Token Access not saving
-
I’m using wpbook-lite, and having some issues when using the Generate Access Token link. The link is not saving. Now I have a few different hosting providers, and on one host everything works fine, and on the other, the link is not saving.
I am using the one click installs of wordpress from both providers, and their permissions are set a bit differently. Is there an easy way to find out which permissions I need to allow for this plugin to work properly?
Is there an option to generate an access code and just hard code it into the plugin by opening up the editor?
-
There is no option to hard code it.
What does the “generate access token” link look like on the blog which does not work?
If the url of the blog doesn’t match the domain listed in the app settings at Facebook (including subdomain – www or none, etc), or if either don’t match the “redirect uri” in the generate access token link, it will fail.
Thanks for the response.
It redirects me to the blog page and reads something like: Access Token Generated on the top of my blog page.
It is not writing to the database successfully though. I was able to fix the problem by creating an access token elsewhere and entering it directly into the database under the wp_options table, wpbooklite-user-access-token (field may not be correct but it is the field in the database that stores the token).
I “think” this is a permissions error.
It works fine on godaddy, but I have had issues and had to use this work around with Pair Networks and Media Temple
Shouldn’t be a permissions problem but may be a configuration problem.
When the permissions dialogue is triggered successfully, the user is returned to the WordPress blog along with a code. (see function wpbook_parse_request at lines 613-645 in wpbook-lite.php).
WPBook Lite has to take that code and go get a token from Facebok, which it then stores in the wpbook_lite_user_access_token option.
My guess is it’s that second stage which is failing, either because WPBook Lite isn’t even seeing the request code or because the @filegetcontents call at line 637 fails.
If it is because your server can’t make outbound calls to Facebook, that may make cross-posting fail as well.
Are you seeing the “Done – access token captured” at the top of the page? If so, then at least I know WPBook Lite *is* getting called appropriately.
Is your home_url() set in WordPress on all the blogs? That’s used as part of the token fetching url.
Thanks again John.
I will have to take some time to look into this. Unfortunately just updating the database is the fastest solution that gets the job done right now, so I’m using it. My memory is a little foggy concerning some of the details – but I’m pretty sure that “Done – Access token captured” is the success message I meant to say instead of whatever I had in the 2nd post.
Once I put that value in the database, the plugin works, i.e. my blog posts do show up on facebook. When I get a chance at home I’ll have to check the home_url().
Thanks again for your help.
Ok, so I delved into this a bit further. When I go to generate the access token, I am first directed to facebook – I go to the app, and allow it to manage my page, etc.
I am redirected to my blog with the success message of :Done – Access Token Captured.
When I go back into wpbooklite, the token field is blank, check database, field is blank too. How would I be able to determine if my server cannot make outbound calls to Facebook? As mentioned, it works if I get an access key somewhere else, and place it directly into the database.
Thanks for the detective work Spike.
Something is failing in the token retrieval call – but the current WPBook Lite isn’t writing out enough diagnostics at that point to tell me why it is failing.
I’ll have to add some more debugging to check for failure conditions in that section of the code.
In the meanwhile, is WPBook Lite able to post to FB successfully when you publish posts?
Yes, when I put the access code directly into the database, it will publish posts to Facebook.
However, now I’m having issues generating a unique access token on any WordPress site.
Not sure what you mean you are having issues generating a unique token – are you trying to reuse the same WPBook Lite on different blogs?
WPBook and WPBook Lite both assume a 1:1 relationship between blog, plugin, and Facebook app.
—
FWIW, I think the issue with storing the token is that the call is using file_get_contents, which is failing on some hosts because they don’t allow fopen (PHP can’t open remote files via file_get_contents).
I’ll need to rewrite it to use cURL which I think the Facebook library does is fopen is not allowed.
Just released 1.2.4, which uses WordPress’ wp_remote_request to get the access token and does some parsing of it.
Can you try that and see? it should try curl, fopen, and other mechanisms and use what works.
John, thanks for being so on top of this.
I will test the new version this evening as soon as I get the chance, and will let you know the results.
Taken me a bit longer than expected to get back to you.
I am having a multitude of problems with this plugin now. One is this error generated when trying to post:
“No post id returned from Facebook, $fb_response was /n and $fb_page_type was and $wpbook_description was test content and $my_title was Test”
When first trying to initiate the plugin, generating the access token usually fails. However, if I try again, it creates a token, and saves it in the database (I noticed that here it is now adding on a expires=###### at the end of the token, when in 1.2.3 it wasn’t).
On another server, I was having issues with PHP safe mode conflicting, but haven’t had any time to test after I disabled that. Version 1.2.3 is working with first attempt at installing this, and I’m just so confused as to why it works on one but not on others?
Is it a problem that I am using my personal facebook to generate multiple apps to link to multiple blogs, and they are having issues granting permissions over each other or something along those lines?
Another subtle thing I am noticing is that when I publish a post, two custom fields are generated for wp-book lite – “wpbook_lite_fb_publish” with value = “yes” shows up twice.
@spike – Thanks for following up. Sorry you’re having difficulty with the plugin. There are many variables at play between Facebook’s changing API, the permissions one can grant, and the various ways WordPress can be configured.
1. No post ID returned from FB.
In general this means permissions somewhere have not been appropriately set, so the FB client does not successfully publish to Facebook and no return id comes back.
Inside WordPress, on the WPBook Lite settings page, there is a “generate access token” link. It should look something like:
https://www.facebook.com/dialog/oauth?client_id=267922346580425&redirect_uri=https://johneckman.com/%3Fwpbook=oauth&scope=read_stream,offline_access,publish_stream,manage_pages
But with different redirect_uri, and different client_id. When you first come to this page, you haven’t yet set the client_id, so the link may be wrong until you do that.
The “expires” in the token may be a problem – you’re explicity granting “offline_access” which should mean that there is no expiration. I just checked my stored token and it does not have expires in it. Does yours, if you visit the WPBook Lite settings page?
2. PHP Safe Mode conflict might have been due to using fopen() call to get the token from Facebook, which 1.2.4 does not do – it uses wp_remote_request instead, which should use curl if fopen is not available.
3. There’s no problem using one FB account for multiple blogs, so long as each blog gets it’s own FB app and therefore client_id. But it might cause confusion for you as to which client_id belongs to which blog.
4. The wpbook_lite_fb_publish value thing is an annoying artefact but does not cause problems – on my list to track down why that happens – seems to be related to revisions in the db.
Finally, the reasons why WPBook Lite sometimes works and sometimes doesn’t are often mysterious to me as well – it works on the half dozen blogs I’ve personally installed it on, but I know lots of people have trouble.
Ultimately, it should never hurt to regenerate permissions / grant access, so long as the correct client_id (App ID) is saved in the db.
One last thought – sometimes the issue is a setting in the Facebook application itself, where you set your website domain – what you’ve set for the application in Facebook has to match what your blog is set as, including the difference between johneckman.com and https://www.johneckman.com
- The topic ‘[Plugin: WPBook Lite] Generate Token Access not saving’ is closed to new replies.