• Resolved zguithues

    (@zguithues)


    when wpbook loads the blog post in facebook the permalinks don’t work.
    hxxps://apps.facebook.com/ohioltc-blog/uncategorized/zachs-introduction/

    the link to my site adds an extra m after the url (ohioltc.comm) the permalink also adds one after the app url.

    i poked around a little and didn’t see where the script creates the link so i couldn’t fix it myself.

    any insight?

    Thanks,
    Zach

    http://wordpress.org/extend/plugins/wpbook/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor B.

    (@bandonrandon)

    My guess is you are using ssl or https inside of Facebook and haven’t set up your app to either have an SSL certificate. If this is the case you either need to 1) disable SSL Security inside Facebook or 2) get/use SSL on your parent site and update your app settings.

    Thread Starter zguithues

    (@zguithues)

    thanks for getting back…

    i have and use a ssl cert on the site, i don’t believe that is the problem. The permalink it creates is (hxxps://ohioltc.comm/uncategorized/zachs-introduction/)
    the script added a m after the baseurl.

    Plugin Author John Eckman

    (@johneckman)

    @zguithues I don’t think we ever planned for FB to switch to https, so you may have hit an edge case.

    The function which recreates the external permalink is in the wpbook.php file, called get_external_post_url($my_permalink) – it basically recreates what it thinks the external permalink should be, since we’ve already filtered it into a FB permalink:

    function get_external_post_url($my_permalink){
      $my_options = wpbook_getAdminOptions();
      $app_url = $my_options['fb_app_url'];
      // code to get the url of the orginal post for use in the "show external url view"
      $permalink_pieces = parse_url($my_permalink);
      //get the app_url and the preceeding slash
      $permalink_app_url = "/". $app_url;
      //remove /appname
      $external_post_permalink = str_replace_once($permalink_app_url,"",$permalink_pieces[path]);
      //re-write the post url using the site url
      $external_site_url_pieces = parse_url(get_bloginfo('wpurl'));
    
      //break apart the external site address and get just the "site.com" part
      $external_site_url = $external_site_url_pieces[host];
      $external_post_url = get_bloginfo('siteurl').  $external_post_permalink;
      if(!empty($permalink_pieces[query])) {
        $external_post_url = $external_post_url .'?'. $permalink_pieces[query];
      }
      //return "app url is " . $app_url;
      return $external_post_url;
    }

    Not precisely sure (still on my first cup of coffee) where it would be getting an extra ‘m’ – but I’d guess we’re somewhere picking it up from https://apps.facebook.com/ bit, since we expect that to be one character shorter (http)?

    Plugin Author John Eckman

    (@johneckman)

    Actually, I think I see the issue.

    It’s earlier in the flow – we first calculate the filtered permalink and then re-create the unfiltered one – we should probably just be skipping the filtering step if “use external permalinks” is checked. (Though then we’ll also have to test what other impacts that might have on category links, page links, tag links, etc).

    The earlier function, fb_filter_postlink($postlink), does contain a hard-coded assumption of http. See lines 974-985:

    unction fb_filter_postlink($postlink) {
    	if (check_facebook()) {
    		$my_offset = strlen(get_option('home'));
    		$my_options = wpbook_getAdminOptions();
    		$app_url = $my_options['fb_app_url'];
    		$my_link = 'http://apps.facebook.com/' . $app_url
          . substr($postlink,$my_offset);
    		return $my_link;
    	} else {
    		return $postlink;
    	}
    }

    What that line which codes in http://apps.facebook.com/ ends up doing is creating a bad internal permalink first, then when the later function tries to recreate the external permalink it gets the extra ‘m’ off of facebook.com.

    If you change line 979 to:

    $my_link = 'https://apps.facebook.com/' . $app_url

    That should fix the calculation of the inside FB permalink first, which should in turn fix the external permalink.

    I’ll have to look at the logic longer term of how we got in this situation to begin with. (We didn’t used to support “use external permalinks” and when we added that I don’t think we thought through the fact that it might be better to just not filter the permalink rather than try to recreate it).

    Thread Starter zguithues

    (@zguithues)

    that makes sense John, thanks.

    I tried the change you suggested and it didn’t effect the links. I even tried re-publishing the blogpost in order to rebuild the links, still no dice.

    Thanks,
    Zach

    Plugin Author John Eckman

    (@johneckman)

    Just checked in a fix for this with a patch from cshiflet (see http://bugs.wpbook.net/view.php?id=41 for details) in version 2.2.3

    Let me know if this fixes the problem for you.

    Thread Starter zguithues

    (@zguithues)

    I just installed 2.2.3 and it works perfect!!

    Thanks a bunch 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Plugin: WPBook] bad permalink in facebook’ is closed to new replies.