Sunday Coding – ReTweeter, WPBook

Two quick Sunday updates.

First, ReTweeter has been updated to 0.9.4. The fix here was primarily to deal with tweets which, when retweeted with the username prepended, were longer than 140 characters.

Second, WPBook has been updated to 1.5.3. This includes a new option to enable publishing to the wall of a Fan Page independent of publishing to the author’s personal wall. (1.5, 1.5.1, and 1.5.2 all could publish to Fan Page walls, but also published to the author’s wall, which in many cases results in duplication for many of your friends and fans.)

Also in 1.5.3 is some improved error checking (fixed the “activation on PHP 4 hosts” bug and added more Try/Catch pairs around Facebook client calls) and the ability to support old school permalink urls with query string parameters.

Good to be home on the weekend . . .

68 Comments

  1. Hi – I just installed the 1.5.3 plugin (I’m using 2.9.2).

    I’ve been struggling the last two days to get WP blog posts correctly appearing on the wall of a FP fan page – so far nothing works, although perhaps the new plugin option will help. The best I can do is get an box to show on the fan page wall – but this box shows only titles, and each blog entry is not of course propagated to my fans.

    Since installing 1.5.3 I now get two new errors that did not appear with 1.5.2. These errors appear when I add a new post on the blog I get the following error message filling the screen:

    One error says: “Caught exception: The user hasn’t authorized the application to perform this action”

    The second error says 1.5.3 that required me to change permissions of the file fbSessionData.txt. I was a able to fix that one.

    However, I the first errors remains, and, frustratingly, I still cannot get blog entries to appear properly on my fan page. Any ideas?

    FYI blog is http://vizbi.org/blog and my FB fan page is http://www.facebook.com/pages/VIZBI/103403666363639

  2. OK solved the ‘Caught exception’ error: it was fixed by adding my blog URL to the ‘Connect URL’ field in the Facebook ‘Connect’ application settings.

    However, as always, still the blog entries do not properly show on the wall…

  3. Sean – when you go the “grant permissions” page (WPBook Settings, “Click here to grant WPBook the permission to publish to your streams”) does it list the page you are trying to target as having granted permissions?

    To get at it another way, if you go to the Fan Page in Facebook, go into “Edit Page” mode, and look at the Application Settings for your Facebook Application, does it show that the application has permission to publish to the Fan Page’s wall?

  4. I’m confused about what you describe as the second error, which required you to change fbSessionData.txt?

    Quick google search suggests that is used by a WordPress plugin called “Status Updater” – it may be that this plugin is conflicting with WPBook?

  5. Also, Sean, what is the url of your Facebook Application?

    Should be something like:
    http://apps.facebook.com/youchosethis/

  6. My FB app is http://apps.facebook.com/vizbiblog

    >fbSessionData.txt and “Status Updater”

    Could be: I enabled and disabled Status Updater around the same time, so this might be unrelated to WPbook. I have Status Updater disabled now, I reverted the permission of that file, and adding blog entries now produces no error. Sorry for the bum steer :)

  7. That did the trick – strangely the page I was trying to add (http://www.facebook.com/pages/VIZBI/103403666363639?v=wall) sometimes was and sometimes was not on that “grant permissions” page. Also: the link that opens the “grant permissions” dialog usually does not work the first time I press it – I had to press twice, and sometimes got two dialogs on top of each other.

    In any case, I FINALLY got my blog entries posted to my wall – THANK YOU JOHN :)

    Now that they are there, I see a small glitch: if you look at the wall (above URL), the latest blog entry shows some HTML that should normally be hidden ([caption id="attachment_238" align="alignleft" width="300" caption="...."][/caption]).

    However, on the application page, the text appears with no HTML code – http://apps.facebook.com/vizbiblog/

    The case occurs I guess because this blog entry has no text, only a title, image, and an image caption.

  8. If you use the “custom excerpt” field when composing posts, WPBook will use that to post to the wall. If you don’t, it instead tries to grab body text and post that to the wall – I guess somehow in the process it bypasses the filters WordPress normally uses to convert [caption] stuff into html.

  9. Hmm, I guess you mean ‘manual excerpts’ not a ‘custom field’? I just tried using both, but it didn’t seem to affect anything. I’ll try with a brand new post.

    BTW is there anyway to add older blog entries to a fan page wall? When I go to the FB application (http://apps.facebook.com/vizbiblog/) I can manually add older blog entries, but only to my FB profile, not to the FB fan pages.

  10. It’s kinda ironic: if I add ‘excerpt’ text, then it displays that correctly on the wall, as you said – but on the application where the entire blog is posted (http://apps.facebook.com/vizbiblog/), the excerpt does not appear, and the caption also not :) Ah well, it’s the fan page wall I’m concerned about, and I have a work-around – THANKS AGAIN for your help John :)

  11. Sorry, yes, “manual excerpts” – the excerpt box that appears generally directly beneath the main body text area when composing a post.

    This will only affect posts newly published to the wall.

    Posting older blog entries would require unpublishing and republishing them – that’s what triggers the update.

    BTW, how’d you manage to turn off commenting on wall entries on your fan page?

  12. The “excerpt” text is entirely separate from the main body text of the post – so whatever you put in excerpt has to be repeated in the main body of the post.

    (Whatever you put in “excerpt” ONLY shows on the wall, and is not then added to whatever is shown in the app.)

  13. >BTW, how’d you manage to turn off commenting on wall entries on your fan page?

    not consciously that’s for sure :) I currently have ‘Allow comments inside Facebook’ and ‘Require Comment Authors E-mail Address’ both enabled. I believe that currently on my FB wall, anonymous comments are disabled, but comments from FB members are enabled.

  14. Hmm, somehow I managed to clobber images – I don’t know if it was adding a ‘excerpt’, but now images don’t appear, even if I do not use an excerpt. But they did appear before. Something funny seems to happens between excerpts, figure captions, and figures. I guess I need more testing to find something workable. For my blog, images are quite important.

  15. @Sean – not sure what could have happened with images. When you say they don’t appear, you mean in the wall post or full version?

  16. WPBook gets images by looking at images “attached” to the post and taking the first one from the array of attached images.

    Maybe you’ve edited those posts in such a way that the image is no longer “attached” in the media manager?

  17. I believe I’m doing the attachement in the ‘normal’ way – using the image ‘Upload/Insert’ button. However I just did some experiment with several different ways to add images – it seems that images do not appear in the FB wall when I upload them from the WP Media Library; however when I upload a new image into WP from, say my computer, it does appear on the FB wall.

  18. Can’t Activate Plugin!

    Parse error: syntax error, unexpected ‘{‘ in [. . .]/wp-content/plugins/wpbook/wpbook.php on line 861

    Use WP 2.9.2

  19. I’ll thank you for the information. My web host provides me PHP5 available. I have to activate it yourself. But this will only taken an hour away.

  20. Hey John! awesome plugin! i seem to be having some trouble getting the app to stream to the fanpage, similar to sean did above. From the fanpage it says the app has permission however from the “grant permissions” page it gives me this:

    This page is just for the author of the blog to grant extended permissions.

    Your userid is XXXXXXXXXXX

    You will need to enter that number into WPBook’s settings page on your WordPress install.

    Click here to trigger extended permissions dialog box

    After you have granted permission, return to the main application: WOULDYOUHIT.IT

    You are also listed as the admin of these pages:

    * WOULDYOUHIT.IT (xxxxxxxxxxxxxx), This page has NOT granted stream.publish permissions to this app

    If you are the administrator of pages which do not show up in this list, you need to ensure you have added the application to the pages first.

    Follow the detailed directions included with the plugin.

    when i click where it says to click a blank box shows up and then it brings me back to the same page.

  21. update:
    i was trying the above before on a mac, i just tried going on a pc and trying to grant permissions and the pop up facebook box wasnt blank this time:

    An error occurred with WOULD YOU? Please try again later.

    API Error Code: 100
    API Error Description: Invalid parameter
    Error Message: When enabling the profile selector, an app may not request user-only permissions

  22. @Dave – never seen the “API Error Code: 100” error you describe above – were you logged into Facebook as the same user when you tried to launch the grant permissions box?

    1. Do you have a “connect URL” defined in your facebook settings for your app? It should be the same as your canvas callback url

    2. When you look at the fan page in “edit” mode, and look at “application settings” for the FB app you created, is there an “additional permissions” tab? If so, what does it say the app has permissions to do?

    So long as it says on the “grant permissions” page that the Fan Page “has NOT granted permissions” you’re not there yet.

  23. i have connect url defined the same as campus callback.

    under fanpage and the fb app application settings it says that:

    ” has permission to:
    Publish recent activity (one line stories) to my wall ”

    which is sort of working i think, as i have a tab called “boxes” on my fanpage with the one line titles of recent posts.

    Some things that might be unique to my site:

    Under Stream Publishing Options:

    Publish new posts to YOUR Facebook Wall, of the wpbook settings i dont have this option checked. I was hoping to just have the fanpage streamed to and not my wall.

    I am running buddypress..

    I am using a plugin called wp-fb connect.

    another factor is im new to this so i may be overlooking something silly.

    Hopefully that forum thread in facebook developers gives some answers soon.. maybe facebook just did some tinkering yesterday to cause this.

    Thanks for your help John!

  24. Great plugin, thanks for your work! Everything is working fine except when it posts to my wall, all the text is run together in one giant paragraph. Does that always happen or is it due to my theme or some other setting?

    Also, any chance we can customize the text it posts to our wall (i.e. instead of ” has published a new blog post at “)? Sorta like how you allow custom headers and footers (with placeholders like %author% etc.)

  25. Facebook takes whatever you post to the stream and strips html from it, which makes the text run together.

    I am looking at ways of formatting the excerpt which gets posted to the stream but don’t have an answer yet.

    In terms of customizing that’s a good idea for later releases.

  26. Hey John!

    just wanted to give an update.. I think facebook fixed whatever was causing the error because i was able to grant permission to stream today!

    thanks for the plugin!

  27. facebook made some changes to fanpages today.. now it offers you to like the page instead of become a fan..

    my app still auto updates from my website but the fanpage no longer auto updates from the app.

  28. Hello!

    Well, I’m pretty happy with what this plugin/app does. I actually what I was looking for.. almost. Because, as you can read above me, the auto update in the wall is not working.

    I tried everything, but in every place my facebbok user has the permission to post whatever into my profile and fanpage.

    I’ve added all I can, everywhere, but nothing.
    Maybe I did something wrong?
    Everytime I try to post something, it tells me:

    Caught exception: The user hasn’t authorized the application to perform this action

    but I can’t where is it that my user doesn’t have that authorization, cause I did all that was necesary.

    If you want to take a look, you can go to app, click here -> http://apps.facebook.com/elrincondelgeek/

    Thanks for this amazin plugin!

  29. @Randall –

    What do you see if you go into WordPress, settings for WPBook, and click on the “click here to grant WPBook the permission to publish to your stream” link?

    1) Does what is listed there as your Facebook profile ID match what you’ve pasted into the “Enter Your Facebook Profile ID” box in WPBook settings?

    2) Are you trying to post to your personal wall, or the wall of a Fan Page?

  30. @John Hello, thanks for the fast reply!

    Well, when I go to the “click here to grant WPBook the permission to publish to your stream”, the app tells me my FB ID.

    I copied that into the Facebook Profile ID as is shown there, and then click the link.

    There it pops up the “gran permission” of facebook, but blank. And it’s like it refreshes the site, and got the same thing, so I click again, and I got this message:

    API Error Code: 100
    API Error Description: Invalid parameter
    Error Message: When enabling the profile selector, an app may not request permissions that do not apply to all profiles in the selector. Note: You are seeing this message because you are a developer of this application. For regular users, inapplicable permissions are silently ignored.

  31. @Randall

    So when you first load the “http://apps.facebook.com/elrincondelgeek/?is_permissions=true” page, does it say, after it tells you your facebook id, that you are also the admin of some set of Fan pages?

    Something like this?:

    ——

    You are also listed as the admin of these pages:

    * MyFanPage (######## ), This page has granted stream.publish permissions to this app
    * MyOtherFanPage (#######), This page has NOT granted stream.publish permissions to this app

    If you are the administrator of pages which do not show up in this list, you need to ensure you have added the application to the pages first.

    —-

    The API Error you’re getting is quite odd – somehow it thinks we’re requesting permissions for places where they are not applicable?

    You are an admin of the fan page you’re trying to post to, yes?

    Has that fan page added your elrincondelgeek app?

    Have you provided a “Connect URL” in the FB preferences for the app?

  32. Well, no that you say it… It’s quite odd what facebok tells me:

    This page is just for the author of the blog to grant extended permissions.

    Your userid is xxxxxxxx

    You will need to enter that number into WPBook’s settings page on your WordPress install.

    Click here to trigger extended permissions dialog box

    After you have granted permission, return to the main application: El Rincón del Geek

    You are also listed as the admin of these pages:

    If you are the administrator of pages which do not show up in this list, you need to ensure you have added the application to the pages first.

    Follow the detailed directions included with the plugin.

    But the funny thing is that I am admin of other fan pages, but none of them are listed… Is maybe some configuration on my profile?
    And no, I have nothing on the “Connect URL”

  33. You should add the application to those pages first – follow the instructions in the PDF included with WPBook or available as a link from your WPBook settings page.

    Only pages which have already added the app can show up on the ‘grant permissions’ page.

    For connect url, go to the settings page for your Facebook app, connect tab, and enter your canvas callback url (generally just the public url of your wordpress install).

  34. by the way, I’m using RPX for my multiaccount loggin. Dunno if that could be a problem, since it also has the FB Connect, but in a different app.

  35. Well, I’m starting to feel stupid for not making this work… :S
    I’ll tell you step by step what I did (which is as is shown in the Instructions within the WP)
    1. I register and app in facebook, I got my API ID and API Secret Key.
    2. In the Facebook APP setting, I add my canvas URL and my callack URL to the blog http://elrincondelgeek.com/
    3. Done in Facebook APP Settings.
    4. Went over my WordPress WPBOOK settings, and the API ID, and the API Secret Key.
    5. Also, added my profile ID, save.
    6. Go over my “Application Profile” in facebook, http://www.facebook.com/apps/application.php?id=116089285081106
    7. Add that to my fanpage going to “add to my page” (in the left sidebar)
    8. There I get prompted to add the Application to my Fan Pages, in which I am admin.
    9. For testing purposes, I added the application to all my fanpages
    10. Go to the WP BOOK Conf page, and cliked in the “click here to grant […]”

    And thats it. The rest I already told you =(

  36. @Randall

    Don’t feel stupid – it’s a complex app to set up, because of the assumptions WordPress makes and the assumptions the Facebook API makes – it is tricky.

    It just means there is something unique about your setup that isn’t in one of my test cases.

    The root of the problem is in the fact that the Fan pages of which your are an admin are not showing up in the list on that ‘grant permissions’ page – until that succeeds you will not be able to post to their walls through WPBook.

    At steps 7-9, when you’ve added the app to all of your fan pages, two questions:

    1) Are all the fan pages showing the ‘latest posts’ box in their profile or boxes tab?

    2) Is one of your fan pages the fan page for the FB application itself?

    I ask the second one because I believe Facebook doesn’t allow an application to post to its own fan page.

    Also, I don’t know if RPX conflicts with WPBook. It may be that they also include the FB PHP library – if so, WPBook detects an existing one and doesn’t include its own (which would cause an error).

    If RPX does include the FB client library, and the version they include is old enough, this could cause a problem – but there error would be something about a function not existing rather than the API error you’re getting.

  37. So, me again.
    I was hoping for this new version (1.5.5) to fix my error, but It didn’t yet.

    Now when I do the “click here to grant WPBook the permission to publish to your stream” I can see all the pages I added this APP. So I give the “stream.publish permission” to the page I wanted, finally. Cool. My fanpage has the permission.

    But I try to grant permission to my user, and first I get this error:

    Error while loading page from El Rincón del Geek Connect
    Configuration errors:
    To fix this error, please set your Connect URL in the application settings editor. Once it has been set, users will be redirected to that URL instead of this page after logging in.”

    So, I do put my URL, which I think is the URL for my wordpress blog, right? And I get this error:

    An error occurred with El Rincón del Geek Connect. Please try again later.

    API Error Code: 100
    API Error Description: Invalid parameter
    Error Message: Param fbconnect must be a boolean

    Can it be some kind of permission I have to grant my Facebook user? Some CHMOD in the server? I really want this plugin to work.. =(

  38. Hello! Even thou I had that error, now i can finally post in my wall and the fan page wall =)

    Here’s an idea for upcoming version of WPBOOK:

    When it get posted in the wall, this gets a “Theres a new post from.. bla bla”
    It could be really nice if there is a way to mix to comments from the wall this the comments of the WPBOOK API, because in my case, most of the peple make their comments in the wall, and not in the post.
    Dunno, just an idea.

  39. Ok, I’m having streaming permission issues too, but this is what I get:

    Error while loading page from 10HappyThoughts
    10HappyThoughts is under construction. Please try again later.

    Configuration errors:
    To fix this error, please set your Connect URL in the application settings editor. Once it has been set, users will be redirected to that URL instead of this page after logging in.

    Can you help?

  40. When posting in wordpress I get:

    Fatal error: Call to undefined method FacebookRestClient::stream_publish() in /home/content/n/o/e/noelyci/html/10Happy/wordpress/wp-content/plugins/wpbook/wpbook.php on line 922

  41. This generally means you’ve got some other plugin that also provides a Facebook client library – like the sociable.es one, for example.

    The version of the facebook client library provided by that other plugin is out of date and doesn’t have the methods for stream publishing.

    You’ll need to either disable that other plugin, or replace their Facebook client library with the one provided by WPBook (in wpbook/client/).

  42. Yes. You need to add a Connect URL in the Facebook settings for your application.

    Just use the same url you used for “Canvas Callback URL”

  43. When I try to activate the plugin I get this error

    Plugin could not be activated because it triggered a fatal error.

    Parse error: syntax error, unexpected ‘{‘ in /nfs/c02/h07/mnt/40616/domains/blog.chicharitomagnetico.com/html/wp-content/plugins/wpbook/wpbook.php on line 861

    Any clues?

  44. Yes. Your host is running PHP 4, and WPBook requires php5.

    What I don’t know is why the check I put in place doesn’t trigger this even before the parse error – but the problem is the PHP version requirement isn’t met.

  45. Some updates:

    I got it to work, intrestingly enough you can’t use a business page to post. The app won’t install on a business page. The workaround which isn’t elegant, is to use RSSGrafiti. I don’t like it. Do you know why their app will install and mine won’t? I believe it probably has to do with their level of developer status, but I’m just guessing. When posting to my personal page it works fine.

  46. Reese – not sure what you mean by a “business page” – but wpbook can be installed to a Facebook Page just fine.

    Are you an administrator of the page in question?

    How are you going about adding it to the page?

    What errors do you get or what suggests that it “won’t install” on your page?

  47. Business pages are pages set up as a business presence, not as an individual, and it won’t let me install the app. I can’t add it to the page. I can add it to my personal page. Here’s what Facebook says:

    What actions can a business account take on the site?
    If you have a business account, you will be able to view and edit all…
    If you have a business account, you will be able to view and edit all of your Pages and ads created with that account. You can take any action on the Pages you administer, including editing your Page information or adding Page content such as photos, videos, and events. You can also view all the statistics related to both your Pages and your ads.

    You will not, however, be able to view the profile information of any other users or add any other applications to your account. For example, business accounts can’t be used to add friends, send messages, or interact with other Pages. Your account will not be visible in search and other users on the site will not be able to find you and add you as a friend.

  48. Can you create an application through a business account?

    How did you install the Developer app from Facebook and create your Facebook application?

    I think pages which were created by business accounts still can have applications added to them – the pages are still just pages, and your business account profile is still a valid profile ID.

    If you go to your application’s page (go to the developer app and then click on your app) where there is an “add to page” link – can you click that link?

  49. Nope, that link dosen’t exist. It does when I sign in on my personal account (seperate user name) but not when I sign in on the one controlling my business page.

    What I find curious about this is that the RSSGrafiti folks got around this somehow. It did a multi step configuration where it asked if it could see my wall, then if it could post to it, then if it could do it when I was offline.

    I realize I’m getting into more of how FB apps should be built, but still, frustrating… since my ‘business’ page has way more people interested in it then me.

  50. So the way that WPBook works is by storing your personal profile ID, and then checking each time, each of the pages for which you are an admin, and whether stream.publish permission has been granted for those pages.

    In other words, it doesn’t try to store the id of the pages anywhere – it only stores your personal id and then checks your pages.

    Maybe in the next version I will add a place to store (and grant permissions for) specific page ids independent of your personal id – that is likely how RSS Grafitti does it.

    This means a bit of refactoring though of the logic for checking for access and how WPBook stores ids.

    Not sure how soon I will get to that, but thanks for the feedback.

  51. Has the problem of Reese Olson anything to do with the difference between ‘Official Pages’, ‘Community Pages’ and ‘Groups’? I’m an admin of a group, and I am unable to add that group to my application. The link ‘Add to my page’ does show, but it says I am not the admin of any page. Everything else seems to work, as far as I can tell (running version 1.5.5 of WPbook).
    I am not into the coding of the application, or the technical background of both facebook and WPbook.

  52. John,

    Thanks for putting WPBook together.

    I have reread the instructions a few times and I must be overlooking something.

    I get the following any time I try to access the application, or edit it from a page.

    Error

    API Error Code: 100
    API Error Description: Invalid parameter
    Error Message: next is not owned by the application.

    —–

    Here is my Canvas and Canvas Callback URL:

    Canvas Callback URL
    http://www.musicmediamoney.com/
    Canvas URL
    http://apps.facebook.com/musicmediamoney/
    FBML/iframe
    iframe
    Developer Mode
    Off
    Application Type
    Website
    Private Install
    No
    ——

    Any help would be appreciated. I would love to use this plugin on several sites!

    Respectfully,

    Stuart

  53. @Stuart – not sure why, but when trying to login to your application, there is a “next” url set:

    http%3A%2F%2Fwww.mmmg.heystuart.com

    No idea where Facebook is getting this url from – is there a “post-authorization redirect” set in your Facebook settings?

    Are you using some redirect mechanism to mask the true domain of your blog?

  54. The problem is that the Canvas Callback URL is different than that domain. Facebook won’t let an application start on one domain and then move to another – so set your canvas callback url to whatever wordpress thinks its url is.

  55. @Deam0n Not currently configurable, but possible.

    Would you want to retweet all mentions, or only mentions from folks the account is following?

    Easiest would be to change the API endpoint Retweeter uses to get the “mentions” feed rather than the “friends” feed – but you’d have to get in and edit some php.

Comments are closed.