Firefox PHP

Sharing (in facebook etc) option, and 'like' option

Posted by mamun965 
Sharing (in facebook etc) option, and 'like' option
June 02, 2011 06:38AM
It'd be great if users can share a topic in facebook, myspace or in other social network sites..
Also, adding a like button in each topic and replies will also improve the forum activity,
so please, experts, help us with these two ideas... thanks
Re: Sharing (in facebook etc) option, and 'like' option
June 02, 2011 04:08PM
I am not one of the "experts", just one of the civilians around here. Last year I started working on a facebook module, and got a bunch of stuff done before I had to stop and switch to some work that would pay the bills. Never did get back to finishing the thing...

Anyway, your request reminded me that I have something. I am not ready to release this as a module here, because it is not 100%, it is not well documented, and I don't have time to support a module that is possibly pre-release quality and then let other phorum users do my QA. In other words, I don't release software like Microsoft does. So this is not a "release". I am just offering some work that is done "as is" because it may be useful to someone.

So if you or anyone else can find some use with this, then enjoy. If it does not work for you, let me know and I won't promise to do anything about it, but I will do my best time permitting. If you are a developer and want to make it better, go for it.

Download a zip with four facebook modules: [docs.google.com]

See the readme in the zip file.

-phil.
Re: Sharing (in facebook etc) option, and 'like' option
June 03, 2011 11:53PM
All I can say is WOW. Single Signon with facebook is possible finally. I only have one question though. Is it possible to make the username the persons facebook display name instead of the email address? I try to protect the privacy of my users by not allowing others to see their email addresses. That change and I think it would be a complete facebook integration as far as using facebook to sign in. I tried the other modules, and it doesn't appear to add the like button, or put the posts on my wall. But that's ok. I'm not a programmer by any means, but I really love the main module. It has great potential if I can figure out how to not use email as username.
Re: Sharing (in facebook etc) option, and 'like' option
June 04, 2011 12:52AM
Thanks for the nice feedback. It would not be terribly difficult to change what the module is doing when it chooses a phorum username. The rationale for it to use an email address was mostly laziness... an email address returned from facebook's API is likely a valid one and I didn't have to code too defensively while relying on it. Also, as an email address is a pretty good global identifier for an individual, it makes the SSO feature more likely to match a facebook user to an existing phorum user.

But the magic line of code to change is in facebook.php line 113. You could change that to whatever you wish and so long as the username meets phorum's core requirements for a valid username (i.e., uniqueness) it will work.

Also, doesn't phorum have an admin feature to control whether the username or display name is shown in Phorum? I've never really looked at it but if it does what I think, maybe that accomplishes what you need. In the facebook module SSO code, a new phorum registration defaults to the facebook user's full name.
Re: Sharing (in facebook etc) option, and 'like' option
June 04, 2011 01:01AM
I'm not sure about that, but I know there is an option to hide their email address, but when their username is their email address that it doesn't work. I don't know how to code all that stuff, but I will look at line 113 and see what it is.
Re: Sharing (in facebook etc) option, and 'like' option
June 04, 2011 01:06AM
$phorum_user_id = phorum_api_user_search("username",$User->email);

I'm assuming this is the line if I Counted correctly. Do I change the word email to something else?
Re: Sharing (in facebook etc) option, and 'like' option
June 04, 2011 01:12AM
I didn't quite understand the last line till I read it 2 or 3 times. The full name would be acceptable.Just so as data miners can't see that persons email address so if people have a disagreement or something, they're not taking the email address and spamming it. But when I signon using facebook, it creates by default a username which is my email address and a password which is also my email address associated with facebook. Not my full name.



Edited 1 time(s). Last edit at 06/04/2011 01:17AM by myperrycounty.
Re: Sharing (in facebook etc) option, and 'like' option
June 04, 2011 02:36PM
I modified the core facebook module to support a new hook (mod_facebook_sso_username) which allows for overriding the default email address as username. Then I added a new extension module (just a simple single file module facebook_sso_display_name.php) to the archive. Try it out, re-download the zip file, update the facebook module, and add the new facebook_sso_display_name.php to your mods folder and enable it in your phorum admin modules section.

[docs.google.com]

The new little module sets the phorum username to the facebook display name stripped of non-alphanumeric characters, and also tests for uniqueness. It will append a numeric suffix to the end as necessary.
Re: Sharing (in facebook etc) option, and 'like' option
June 04, 2011 02:52PM
BTW, posting to the facebook wall requires the facebook user to give permissions. The facebook module could very easily just assume the right and do it by default. By I personally find that very intrusive so instead I made it an optional right. Go to your phorum control center and under Options check out the "Facebook Profile" panel. Under the "Expanded Data Permissions (optional)" section there will be items to "Submit my posts to my Facebook wall." If the user checks this he or she will be routed through facebooks authorization flow, and if they agree then it will be done. At that point, the user is given additional controls in the phorum posting form to publish posts to their wall.

As for likes and sharing, the Facebook: Post Topics module adds these features (as well as the posting to wall), but they are not inserted into templates for you. Instead, the widget code is added to the phorum data so you can then modify your templates to put them where you want. Sorry there is no documentation for all that stuff :) But read the little Help snippets in the Facebook Module Settings, they will tell you what the variables are named.
Re: Sharing (in facebook etc) option, and 'like' option
June 05, 2011 01:38AM
Thanks, You are friggen awesome. I have a completely cram packed weekend and won't get a chance to try it out till tuesday or wednesday. But thanks again. This is something I think a lot of people have been waiting for for a long time. The single signon alone is valuable. As far as the posting to wall, I had those options checkmarked and it didn't appear to work. But in all fairness I need to play around some more and I'm not too much worried about it as the SSO is the main thing I've wanted.
Sorry, only registered users may post in this forum.

Click here to login