Creating Facebook ID Card with PHP Facebook SDK
You may have came across some images about horoscope or stats about profile visitors on friends wall, aren’t they just fun to read? Well, why not create something fun like that? may be a Facebook ID card? Today let’s focus on creating some authentic looking “Facebook ID” for the users using PHP and PHP Facebook SDK.
We will be merging image files and writing text on Facebook ID card, so make sure GD is properly working. I have included PHP Facebook SDK and free font DidactGothic.ttf by Daniel Johnson in downloadable sample file below.
Everything takes place in just one PHP file here, as usual we will show a Facebook log-in button and the user data we fetch from Facebook will be used to create Facebook ID card for the user. Here’s a look at our initial PHP code for Facebook SDK:
Once we have the session, we can then we fetch Facebook User data:
Generating ID card
Now we copy user profile image to local server using PHP copy() function, merge profile image with ID card image template, and then we write text to the image using TrueType fonts.
Below you’ll find entire PHP code that generates Facebook ID card. The comment lines should make things easy for you, to make it more easier you can download entire file at the bottom of this article.
This is just example of what else you can do to make fun pictures for your Facebook users, all you need is an idea, download sample file below and don’t forget to checkout the demo, please share you thoughts also, good luck!
Saran Chamling. (He loves the web technology, and enjoys designing, exploring and writing about it @saaraan.com).