Do my own plugin

Do my own plugin

Hi, everybody!

I was considering using CB for handling custom user fields, but actually I do not need it.
So (call me crazy) I am considering creating my own JFB Connect Plugins to fill my tables with user data from facebook.

Please just check if I am getting this right:


  1. I will leave "jfbconnectauth" and "jfbconnectuser" published and unchanged to handle the Joomla / Facebook integration

  2. I need to create my plugin with type "jfbcprofiles"

  3. In that plugin I will define "class plgJFBCMyConnectPlugin extends JFBConnectProfileLibrary"

  4. I must handle data import from facebook in the following trigger functions:

    Code:

    function jfbcProfilesOnRegister($jUserId, $fbUserId)
    
    function jfbcProfilesOnAuthenticate($jUserId, $fbUserId)
    function jfbcProfilesOnLogin()



Is this it? Am I missing something?

A couple of questions:
  • What is the difference between "jfbcProfilesOnAuthenticate" and "jfbcProfilesOnLogin" triggers?
  • Must I create triggers "jfbcProfilesOnShowRegisterForm" and "jfbcProfilesSendsNewUserEmails" (just returning "true" - I do not need any actions on these events) or can I skip that?


Errr... do you have any API-like documentation? current/wink

Thanks a lot and congrats on a GREAT component!

fb_100000157901698
Alexandre
useravatar
Offline
76 Posts
Male 
Active Subscriptions:

None
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Do my own plugin

We're working on more developer-friendly documentation, but hopefully we can help you through everything you need to know here for now!

Your general idea is spot-on. Just create the JFBCProfile plugin and don't touch anything else. We've tried to make it easy to do what you're saying so that you don't have to modify any of our code, which will let you upgrade JFBConnect easily and not have to re-implement your code.

The 3 functions are the main ones to look at. The other one you'll want is "addFieldToDb". Here's a quick overview of the functions, but please test and ask questions as I may be wrong on something:
jfbcProfilesOnAuthenticate($jUserId, $fbUserId) - Used for checking if the user is allowed to login. You'll likely just return true here (or don't even implement it)
jfbcProfilesOnRegister($jUserId, $fbUserId) - Used to do stuff on the first time a user registers on your site. Most of our plugins just call the same logic as OnLogin (below)
jfbcProfilesOnLogin() - Used to do something when the user logs in. This is usually where the users profile is imported from FB into a database. Generally, this should just call parent::importFBProfile(); which will call the function below repeatedly to make your life easier.
addFieldToDb($fieldId, $value) - This should take a fieldId (set in your usermapping) and hand you the value from Facebook to use in that field. You can figure out what to do with it from there (write to file, write to your table, etc).

The mapping of fields from your table to Facebook is configured in the /tmpl/configuration.php file of your plugin. Here, just put select lists for each of your fields, give them an integer id (used as the $fieldId in addFieldToDb) and show the Facebook fields to map to it (see other profile configuration files for reference). Once this is saved, then when the user is logged in, we'll call addFieldToDb repeatedly with the id and actual value from the user's profile for you, so you just have to 'do' something with those tidbits of info. Additionally, by using the usermap functionality, JFBConnect will automatically ask for the permissions you need to get that information.

Finally, the only last bit of knowledge to impart is that you need to setup the constructor similar to the other profile plugins. Mainly, the settings value which are any settings for the plugin you'll want to save in the database to use later as well as a component directory to check if you're profile plugin is installed.. since you may not have one, you probably can just put JPATH_ADMINISTRATOR there so that JFBConnect always thinks your plugin should run.

Hope this all helps, and again, ask questions. This post will likely be the start of a document we'll throw up on the main JFBConnect overview page, so thanks for forcing us to finally start jotting this stuff down! current/smile

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
24020 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Do my own plugin

Just a note to say I followed your instructions and my little plugin works just fine.

And now, I am also putting

Code:

require_once(JPATH_SITE.DS.'components'.DS.'com_jfbconnect'.DS.'libraries'.DS.'facebook.php');

in many of my files... and using it intensively current/big_smile

Thank you guys, for saving me all the headaches of dealing with Facebook programming... you are the true "Operation Developer Love".

fb_100000157901698
Alexandre
useravatar
Offline
76 Posts
Male 
Active Subscriptions:

None
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Do my own plugin

Alexandre,
That's fantastic to hear, and we're glad to hear you're really getting along with JFBConnect. Certainly if you need anything else from us, just let us know.

Finally, I'm not sure if you left a review on the JED, but there was one recently from someone named Sylvester who had done some programming of a profile plugin... if that was you, thank you very much for your time. It's very appreciated.

Best of luck to you,
Alex

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
24020 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Do my own plugin

Yes, sir... that whas me on JED.
"SylvesterFaro" is my funny username (check the avatar) - JED shows "username" and not "name".

I take the oportunity to suggest you do show "name" and not "username" in this forum... its harder to recognize " fb_100000157901698" as the coolest guy in the forum. current/wink

fb_100000157901698
Alexandre
useravatar
Offline
76 Posts
Male 
Active Subscriptions:

None
Administrator has disabled public posting. Please login or register in order to proceed.

Re: Do my own plugin

I meant to mention your avatar after I said Sylvester.. I made the connection current/smile

We've considered changing what we show as the name.. but also, in the upcoming 4.0 release, we've already implemented a way (for an admin) to select the auto-generated username by either setting it to:
fb_123456 (what we've done for a while)
First.Last22 (FirstName followed by . followed by LastName followed by small unique ID)
FirLas22 (first 3 chars of first name followed by first 3 of last name followed by unique ID)

Once we get that up, we'll probably move to that system so you (don't know your last name, lets assume it's smith) would have had an auto name of "alesmi22" maybe current/smile

Thanks for the suggestions and the review, and best of luck with your site!

If you use our extensions, please consider leaving a rating and review at the Joomla! Extension Directory:
JFBConnect | SCLogin

alzander
Alex
useravatar
Offline
24020 Posts
Support Specialist
Administrator has disabled public posting. Please login or register in order to proceed.
There are 0 guests also viewing this topic
There are 0 users also viewing this topic

Board Info

Board Stats
 
Total Topics:
11615
Total Polls:
0
Total Posts:
48806
Posts today:
4
User Info
 
Total Users:
47663
Newest User:
genesis678
Members Online:
1
Guests Online:
1104

Online: 
ramonmedina
Social Stream
SourceCoast Joomla Social Extensions
Friday, 25 May 2018
JFBConnect 8.0 Coming Soon! Stay tuned.
Refer and Earn

Like our extensions? You're not alone! That's why they're used on tens of thousands of websites. Now you can earn 20% of any sale you refer to SourceCoast.com.

We provide excellent documentation, well laid out sales pages and great support. All you need to do is spread the word and we'll take care of the rest.

Learn About Our Affiliate Program