Topic-icon can I get access to a user's Facebook username?

Active Subscriptions:

None
13 years 9 months ago #26122 by danell
After users log in to my site through Facebook, they can create content on my site. Their username is associated with that content. When another user of the site views that content, I want to show the creator's Facebook profile picture along with the content itself.

It looks like you can easily retrieve a Facebook user's profile picture provided that you know their Facebook username. Is this stored anywhere in our database? If not, do you have any other suggestions as to how I could show the user's profile picture to someone viewing the content they created?
The topic has been locked.
Support Specialist
13 years 9 months ago #26125 by alzander
To get the user's avatar, you need their Facebook ID. That is stored in the database in the xyz_jfbconnect_user_map table which links their Facebook ID to their Joomla User ID. There are a few ways to get this out, but it sounds like you know what you're doing. It's a simply MySQL query at it's easiest, but we also have some Models and things you could use to get it. If you need help, just let me know.

Once you get that FB ID, you can simply link to the user's avatar image like:
<img src="https://graph.facebook.com/<?php echo $fbUserId; ?>/picture?type=large" width="50" height="50" />
Where $fbUserId is the user's Facebook ID that you want to show. So, for example, my avatar link is:
graph.facebook.com/1251253607/picture?type=large
You can also use small, medium, or some other sizes there to get something more appropriate for your needs.

Hope that helps!
Alex
The topic has been locked.