Forums

[resolved] WPBook 1.2 Head Problem (30 posts)

  1. zzzbrett
    Member
    Posted 7 months ago #

    I'm trying to setup WPBook 1.2 on my blog, but am having some troubles. The first problem is, whenever I click on one of the posts from within the facebook app, it loads the post ok, but the facebook client file attempts to modify header info, so it throws some warnings.

    i have some other problems, but i'm hoping once this is fixed, the others will as well.

    Blog URL: http://brettshaffer.com
    Facebook URL: http://apps.facebook.com/brettshaffer/

    Thanks

  2. johneckman
    Member
    Posted 7 months ago #

    @zzzbrett - Released 1.3 today, but honestly I don't think that will have any impact on your issue, which I've not seen before.

    It's claiming that the Facebook client php code (which tries to set a cookie) is trying to modify the headers after the page has already started loading - but what's odd is that it doesn't do so on the index page (list of posts).

    In either case, the facebook client config.php file is called in long before the page starts outputting.

    Have you modified /wp-content/plugins/wpbook/theme/index.php at all?

    Using any WordPress plugins that do something unique with cookies?

    Lastly, any chance you could try it out somewhere that isn't XAMPP based?

  3. zzzbrett
    Member
    Posted 7 months ago #

    I've deactivated all plugins, completely removed WPBook 1.2, installed 1.3, activated it, and set WP to the default theme. I still had that same problem. If any modifications I may have done to index.php were at fault, they should have been reset by the new installation of the plugin. No other WP plugins were active, so no cookie changes should have occurred.

    No, currently this is the only server I have available.

    Any other ideas?
    I'll go ahead and give you some other problems I have, in case they have something to do with this one..

    1. At top of app (blog), where it shows title, it links to: http://apps.facebook.com// instead of http://apps.facebook.com/brettshaffer/ or http://brettshaffer.com (not sure which one it should be linking to..)

    2. The options for WPBook don't seem to be working.. For instance, I check the options to give WPBook credit, and to show the external links, but neither show up (as far as I can tell).

    Hope this helps,
    Brett

  4. zzzbrett
    Member
    Posted 7 months ago #

    I did some further testing. Using a fresh install of wordpress, downloaded straight from wordpress.com, I deleted all other plugins and installed wpbook 1.3, created a new facebook app via facebook.com/developers, and still have the same problem.

    URL of this test blog:
    http://apps.facebook.com/wp_test/

    If no one else is having this problem, I guess it has to be my server? Although I have no idea why one http server setup with php is different than another..

  5. BandonRandon
    Member
    Posted 7 months ago #

    zzbrett,

    I was able to add your application and it seemed to work fine. The test app seemed to be broken.

    Any information on the error messages in the header would be great.

  6. zzzbrett
    Member
    Posted 7 months ago #

    BandonRandon:

    To reproduce the header warnings, goto http://apps.facebook.com/brettshaffer, then click on any of the posts. At the bottom, before the comment section, you will see four errors.

    The errors are as follows:

    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\client\facebook.php on line 330
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\client\facebook.php on line 330
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\client\facebook.php on line 330
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\brettshaffer\wp-content\plugins\wpbook\client\facebook.php on line 334

    Thanks,
    Brett

  7. zzzbrett
    Member
    Posted 7 months ago #

    UPDATE: Please use the test blog now to view the problem. I have edited the code, simply commenting out the lines that set cookies. I'm not sure what kind of adverse effects this may have, but it works for now. Still looking for resolution to original problem though.

  8. zzzbrett
    Member
    Posted 7 months ago #

    UPDATE 2: I'm going through and making temporary changes to the code to fix my problems. Again, to view original problems (still not resolved), please use the following link:

    http://apps.facebook.com/wp_test/

  9. BandonRandon
    Member
    Posted 7 months ago #

    Call me Nieve but the problem I'm seeing in the test blog is this one repeated 4x.
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\qrxx\blog\wp-content\plugins\fbconnect\facebook-client\facebook.php on line 334

    What is the "fbconnect" plugin?
    What is line 330-334 of the file it's calling.

    What looks to be happening to me is that fbconnect is calling the facebook.php library then wpbook is trying to call it again. What changes did you make in your actual blog to resolve this.

    Also did you see the wp "other notes" that says this about fbconnect (I can only assume it's the same plugin)

    NOTE: These 2 plugins have been reported to conflict with WPBook: - Bad Behavior - Facebook Connect (from Sociable.es)

    I'm working on identifying and eliminating conflict, but you should not try to use WPBook with either of these plugins in the current state.

    (Note there is a workaround for the Sociable.es Facebook Connect plugin described here: http://bit.ly/hhach)

    on John's site this is the workaround.

    Change line 170 of /wp-content/plugins/fbconnect/facebook-client/facebook.php from:

    http_header('Location', $url);

    To:

    header('Location', $url);

    This will eliminate the conflict between these two plugins.

    I couldn't tell you if this is the issue you're having. I also really appreciate you taking the time to post and help us troubleshoot this issue.

  10. zzzbrett
    Member
    Posted 7 months ago #

    Sorry for the confusion. I was messing around with some other facebook plugins as well and didn't realize they changed the error. I deactivated all other plugins again, and the original problem arose again:

    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\client\facebook.php on line 330
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\client\facebook.php on line 330
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\client\facebook.php on line 330
    
    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\theme\index.php:56) in C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\client\facebook.php on line 334

    You can witness it by visiting the same URL.

    Thanks

  11. johneckman
    Member
    Posted 7 months ago #

    @zzzbrett - thanks for going through the effort to set up a vanilla test blog - very useful.

    Something is definitely odd here - I was able to view the blog posts and then (after the fact) go pushed to the "Grant Access" dialogue from facebook.

    Somehow the Facebook client code, which is invoked through the "include config.php" line in /wpbook/theme/index.php is getting executed by your server *after* some of the page has already been returned to the client.

    That is, the facebook.php line 330 mentioned in the error message seems to be called *after* the index.php line 56 also mentioned in the error message, which should not happen.

    Why, I don't know. Can you share the specific version of Xampp you're running? (If you don't want to post publicly you can use the comment form at my blog).

    I can only guess that there might be something different about the way XAMPP handles includes in PHP (5? or are you running 4?) that is different - but I've got virtually no experience with XAMPP.

  12. johneckman
    Member
    Posted 7 months ago #

    Ok, I think I got it. It is a line endings problem.

    The first line in /wp-content/plugins/wpbook/index.php is not successfully including config.php.

    First three lines of that file look like this:

    <?php
    // the facebook client library
    include_once 'config.php';

    I think what's happening is that the include_once line is getting read by XAMPP as part of the comment.

    I'm writing code on Mac OS X - could it just be a simple line endings problem? Try opening that file in windows and adding the line break back in.

  13. johneckman
    Member
    Posted 7 months ago #

    Oh, and the reason it looked the include was firing late is that it is included again when the comments.php file is used later on in the same page load (in cases where the comments form is visible, ie, not on the list page) - I assume that second call to the same include is unnecessary and I'll remove it next release. (1.3.1).

  14. zzzbrett
    Member
    Posted 7 months ago #

    johneckman,

    Thanks for the response.

    I checked out index.php, and the include line was not commented out. I verified this by changing the name of the file it was including, and it resulted in an error stating that the file could not be found.

    About the second call from comments.php -- I assume you are referring to the call to client.php, the facebook library of functions -- I commented out this and it resulted in a fatal error, stating it was missing one of the facebook functions.

    Also one more thing: this is by no means meant to be demeaning or insulting in any way - as I'm sure you already know, XAMPP is a package install of the Apache HTTP server that includes preconfigured extensions for PHP, among some other things. So the fact that this is a XAMPP install (in my opinion) should not be a large factor. Maybe it is an issue with the Apache server version / config or the PHP version / config -- not the fact that it was installed as a package (xampp).

    Here is my server information:
    Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8

    Thanks again for the support and development of this great plugin. Let me know if you'd like me to try anything else.

  15. zzzbrett
    Member
    Posted 7 months ago #

    Edit to above: facebook.php in the client folder, not client.php

  16. johneckman
    Member
    Posted 7 months ago #

    Thanks zzzbrett.

    I am familiar with XAMPP - I think the issue is a windows issue.

    So the first include (of config.php) in theme/index.php does happen.

    What's interesting is that when you removed the second call to /client/facebook.php (the one that happens inside comments.php) the code failed - that should not happen, since the facebook client should already have been included and instantiated earlier, from config.php which is included at the beginning of index.php.

    What about this function, which is the beginning of the config.php?

    <?php
    // the facebook client library
    if(!class_exists('FacebookRestClient')) {
      if (version_compare(PHP_VERSION,'5','>=')) {
        include_once(ABSPATH . 'wp-content/plugins/wpbook/client/facebook.php');
      } else {
        include_once(ABSPATH . 'wp-content/plugins/wpbook/php4client/facebook.php');
        include_once(ABSPATH . 'wp-content/plugins/wpbook/php4client/facebookapi_php4_restlib.php');
      }
    }

    Is it possible that this code fails somehow? Since you know you're on PHP 5, change the lines above to this:

    <?php
    // the facebook client library
    if(!class_exists('FacebookRestClient')) {
    include_once(ABSPATH . 'wp-content/plugins/wpbook/client/facebook.php');
    }
  17. zzzbrett
    Member
    Posted 7 months ago #

    The change was made, but still no luck - same error. Where in wpbook is comments.php called?

  18. johneckman
    Member
    Posted 7 months ago #

    Basically the way WPBook works is by recognizing when the blog is being called from Facebook (function is check_facebook() defined in wpbook.php) and substituting it's own theme (in wpbook/theme/) for the blog's currently active theme outside Facebook.

    This means that comments.php isn't really called in a typical include but in /wpbook/theme/index.php at line 198 is the WordPress comments_template(); call which results in the comments.php being executed.

    What's odd is that when the /wpbook/theme/index.php is called, the first line calls in config.php, which in turn calls in facebook.php, and does the following at line 136 (of config.php):

    $facebook = new Facebook($api_key, $secret);
    $user = $facebook->require_login(); 
    
    $params = $facebook->fb_params;
    $user_id = $params[user];

    These all rely on facebook.php having been included and should fail if it is not active. (Unless maybe it is active because some other plugin has already loaded it?)

    All of that loading should happen before the rest of index.php starts to be returned to the browser - so before the "headers already started" error you're getting.

  19. zzzbrett
    Member
    Posted 7 months ago #

    I understand.

    It can't be other plugins, because that is the only one activated.

  20. johneckman
    Member
    Posted 7 months ago #

    Sorry I can't be of more help - I'm a bit stumped. ;)

    What happens if you comment out the includes of wpbook/client/facebook.php that are currently in wpbook/theme/comments.php?

    Do you get errors about facebook not being defined?

  21. johneckman
    Member
    Posted 7 months ago #

    The fact that you don't see other WPBook options taking effect suggests to me that the code in wpbook/theme/config.php is not getting executed somehow.

    Any chance you could put an error_log() function in there and see if config.php is executing? Maybe right around where the calls to the facebook class are? (Lines 136-140)

    I'm going to have to install a XAMPP and play with this a bit - sorry for the difficulty, but you've clearly found some kind of bug.

  22. zzzbrett
    Member
    Posted 7 months ago #

    I assume you mean comment out the include line in the following code `<?php
    // the facebook client library
    if(!class_exists('FacebookRestClient')) {
    include_once(ABSPATH . 'wp-content/plugins/wpbook/client/facebook.php');
    }`

    After doing that, I get the following error:
    atal error: Class 'Facebook' not found in C:\xampp\htdocs\qrxx\blog\wp-content\plugins\wpbook\theme\comments.php on line 20

    I am stumped as well. I've seen some PHP debuggers out there - maybe i'll look into one of those (never used one).

    In summary what we've found is that -somehow-, the comments.php file does not have access to the facebook.php client library, even though before comments.php is called, it is included. I can't think of any reason that it wouldn't be included. But, for now, the commenting out the lines that cause warnings works just fine.

    Again, if you think of anything else I should try, just let me know.

  23. zzzbrett
    Member
    Posted 7 months ago #

    It doesn't look like config.php is being called at all. Maybe you're onto something.

  24. zzzbrett
    Member
    Posted 7 months ago #

    I think its fixed!

    I edited the line:
    include_once 'config.php';
    to
    include_once(ABSPATH . 'wp-content/plugins/wpbook/theme/config.php');

    and... no more errors!

    I have no idea why the first method didn't work. I changed the first line to a different filename, and it threw an error - so I know it found the file.

    Nice job on thinking about the other problems.

  25. zzzbrett
    Member
    Posted 7 months ago #

    It seems that most of my other problems are fixed as well now! The option to give credit to you is working, as well as the link at the top of the blog is fixed.

    Only option that isn't working is the 'view in external site' - either its not working or i'm just not seeing it - but that is a small problem compared to the original :)

    Thanks alot for all your help.

  26. BandonRandon
    Member
    Posted 7 months ago #

    Sorry to jump back into the middle of the ongoing conversation. I'm glad you two seem to have the issue worked out.

    I developed the "view in external site" function and so this not working alerted me. Is it doing anything? What it should do it show a box that says "view post on example.com" next to the share link.

    This function works basically by taking apart the facebook url adding the wpurl to the front and then the permalink to the back.

    Thanks for all your willingness to troubleshoot.

  27. zzzbrett
    Member
    Posted 7 months ago #

    BandonRandon,

    After further investigation, all of the 'view on external site' links work fine except one (of course the one I tested). This may have something to do with the fact that, in the post's URL, it has the blog's domain name. This may have interfered with the method you are using to take apart the facebook URL.

    See Here:
    WPBook: http://apps.facebook.com/brettshaffer/
    WPBook View External Site Link: http://brettshaffer.com/newscom-now-on-facebook/
    Actual External URL: http://brettshaffer.com/news/brettshaffercom-now-on-facebook/

    Hope this helps.
    Brett

  28. BandonRandon
    Member
    Posted 7 months ago #

    Brett,

    Yeah that makes sense that it's breaking because the permalink contains the url in it. I noticed the post below it "BrettShaffer.com now OpenID Ready!" the title has the url but not the actual permalink and this works fine.

    The code for the external site url is below.

    <?php
    // code to get the url of the orginal post for use in the "show external url view"
    //get the permalink
    $permalink_peices = parse_url(get_permalink());
    //get the app_url and the preceeding slash
    $permalink_app_url = "/".$app_url;
    //remove /appname
    $external_post_permalink = str_replace($permalink_app_url,"","$permalink_peices[path]");
    //re-write the post url using the site url
    $external_site_url_peices = parse_url(get_bloginfo('wpurl'));
    
    //break apart the external site address and get just the "site.com" part
    $external_site_url = $external_site_url_peices[host];
    $exteral_post_url = get_bloginfo('wpurl').$external_post_permalink;
    
    //echo external post url
    echo "<a href='$exteral_post_url' title='View this post on the web at $external_site_url'>View post on $external_site_url</a>";  ?>

    Basically the way this works is because wpbook core re-writes all permalinks with apps.facecbook.com/appname/permalink. The external site needed to undo this structure. The code above takes the article permalink removes the appname/ part then adds the permalink back to the original site url.

    Sorry if I'm boring you I'm sorta thinking out loud. I just noticed that the appurl and the permalink piece "brettshaffer" are the same and I belive this is the problem that it's replacing both the "/brettshaffer" in the app name and in the permalink leaving just the newscom instead of news/brettshaffercom. You defently found a bug for now I don't have a clear solution except for to change the permalink in wordpress.

    Thanks again for your help. If you have any ideas they are welcome. Hopefully we'll have this fixed soon.

    Brandon

  29. zzzbrett
    Member
    Posted 7 months ago #

    I guess I have a talent for finding bugs inadvertently. Your explanation makes perfect sense. I'll try tweaking the PHP code this weekend and see if I can come up with anything.

    Thanks,
    Brett

  30. zzzbrett
    Member
    Posted 7 months ago #

    'Resolving' this thread because the original issue was resolved.

    Continuing here:
    http://wordpress.org/support/topic/256638

    Thanks for the help!

Reply

You must log in to post.

About this Topic

Tags