Horror Profile Facebook application source code released
Horror Profile is a Facebook application I developed a month ago.
Now it’s time to release the source code. You will find some useful tips about dynamic image creation with php.
If you are absolutely new to Facebook applications, I suggest you to read “Developing a Facebook Application for absolute beginners” posts 1, 2, 3, 4 and 5.
The idea is simple: placing the profile picture in a mirror (that is a transparent PNG image) and writing the user first name as big as I can. Read more
Creation of a Flash Facebook application using AMFPHP
Some days ago I showed you how to create a Flash Facebook application using the AS3 API.
Now Yarden Refaeli from Rigel Games is sharing with us his experience in creating a Flash Facebook application using another technique.
Let’s read it:
« Hello, my name is Yarden Refaeli and I have been flash programmer for 1 year. A few weeks ago, I decided to make my first facebook flash game, Snaker. Well, I won’t lie: It was HARD. After I made it to the end, I decided to write a tutorial about the best approach to build flash-facebook game. So let’s start!
First, we need to save our meta user-data about every user in OUR database, and for this we need to use a server-side language (in this tutorial I will talk about Mysql, but every other database or server-side language is fine).
Let’s say we want to make a game that save our score at the end, and then show us the score we got, and the scores of our friends. We need to save the score for every user, with it’s unique id, which can easily access through facebook APIs. Now lets say we want to do all the server-side jobs, with PHP and not flash: we don’t want to get the user-data we need from facebook-flash API, then send it all the way to the server and store it in the database, we want ALL the facebook/database related work, done on the server-side, with PHP. You should know, that you can access simple facebook library PHP code from flash, you need to authenticate first with the facebook function “set_user” with your user’s uid, and session key, that passed via the FBML tag in the flash vars. (for some strange reason, there is NO official documentation for this function AT ALL) Read more
Creating a Flash Facebook application with the Facebook Actionscript API – part 2
It’s time to make some considerations on the Facebook application made with the Facebook Actionscript API I blogged some days ago.
There was a doubt about putting a secret key in the swf file.
Well, you should never give away your secret key, but let me point on two things:
1) You can encrypt your swf file, obfuscating the secret key… and just in case you think nothing is encrypted enough… surprise…
2) My Facebook application works without api and secret keys. That’s it… I tested it with more than one account, and everybody was able to use the application even if my keys are stored this way:
var api_key:String="xxxxxxxxxxxxxxxxxxxxxxx";
var secret_key:String="yyyyyyyyyyyyyyyyyyyyyyy";
I am not hiding them, they are really a series of x and y… probably when you render a swf in canvas mode, they aren’t mandatory.
I have to say, I did not find docs about it, so take it as it comes.
The feature introduce this time is showing all your friends… there was a reader that was unable to populate a list with friend names, so here it is.
I didn’t create any list, but I’m simply showing them in a text area. Read more
Creating a Flash Facebook application with the Facebook Actionscript API
It’s time to see how can we build a Flash Facebook application.
What we are going to do is a Flash movie to be embedded in a Facebook application, able to interact with the user by publishing notes and stories on the wall.
The first thing we need is the official Facebook Actionscript API. This library contains all we need to create a complete Facebook Flash application.
You can download the source code at this link, but before messing with AS3, let’s create the PHP part.
I suggest you to read the Developing a Facebook Application for absolute beginners posts from 1 to 5 if you don’t know how to create a basic Facebook application.
Then, take a look at the PHP code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <style> < ?php echo htmlentities(file_get_contents("style.css", true)); ?> </style> <script> function grant() { document.setLocation("http://apps.facebook.com/flash_demo/"); } </script> < ?php require_once "facebook.php"; $appapikey = "xxxxxxx"; $appsecret = "yyyyyy"; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login(); $has_permission = $facebook->api_client->users_hasAppPermission("publish_stream"); if(!$has_permission){ ?> <div class = "allow">You won't be able to test the flash demo if you don't allow publish stream permission - <fb :prompt-permission perms="publish_stream" next_fbjs="grant()"><strong>ALLOW PERMISSION</strong></fb></div> < ?php } ?> <fb :swf swfsrc="http://www.gamemummy.com/facebook/flash_demo/facebook_demo.swf" allowscriptaccess="always" bgcolor="#ffffff" flashvars="" width="500" height="400"/> |
Notice at lines 1-3 the way you can import CSS style sheets. Don’t forget to use htmlentities on the imported file.
Then, at lines 5-9 I created a simple javascript function called grant that just redirects the browser to the application page. That is, basically it refreshes the page, and it will be called once the user will grant (or won’t grant) the permission to publish contents on his wall by submitting the permission form as you can see at line 30.
This is possible thanks to next_fbjs="grant()".
Another important thing in this script you should arleady know is the way I ask for publishing permission.
You can ask for permission inside the Flash movie itself but I found it easier to ask directly from Php. This way, you can even hide the Flash movie if the user does not grant permissions.
But the core of the script, the think you did not see in previous tutorials is the way I include the Flash movie at line 34 with the fb:swf tag.
You can find the official documentation at this page, and the most interesting thing is Facebook is passing some interesting parameters to the movie. Read more
Horror Profile: Facebook application
You are all invited to try Horror Profile, a Facebook application I made in about an hour.
The application takes your name and profile photo, and combines them in a creepy environment to create an horrific photo that you can upload to your album.
During next days I’ll release the full tutorial to create an application with ads, photo uploads, dynamic text generation, and all the features you see in the application.
Meanwhile, Play with it.
Developing a Facebook Application for absolute beginners – step 5
Welcome to the 5th step.
Let’s make a small recap:
Step 1: Creation of the application itself
Step 2: Publishing a text on the user’s status
Step 3: Publishing text, links and images on the user’s wall
Step 4: Inviting friends to use the application
Now it’s time to make the application post a notification to users you invite to join the app.
I mean this one:

The script now is this one: Read more
WordPress plugin prototype to check the date and time that wp files have been last modified
Like some of you noticed during these days, my blog was hacked.
Someone injected an encoded javascript code into my footer.php theme making my site open an iframe with some badware.
The same old things that happen when you’re famous :)
The boring part of this story is now I check for my WP files every day, to prevent code injection, until I’ll find the way hackers use to inject such code.
So I developed a very basic plugin to do this job for me. It scans my themes directory and outputs the files modified in the last 24 hours.
I don’t know if I’ll turn this prototype into a real, finished, plugin… but meanwhile you can take a look at the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <?php /* Plugin Name: Check file dates Plugin URI: http://www.emanueleferonato.com/ Description: Checks the date and time that wp files have been last modified. Author: Emanuele Feronato Version: 1.0 Author URI: http://www.emanueleferonato.com/ */ add_action('admin_menu', 'add_plugin_pages'); function add_plugin_pages(){ add_menu_page('Check dates', 'Check dates', 8, __FILE__, 'mt_toplevel_page'); } function date_tree($start_dir,$date){ $dirs = array_diff(scandir($start_dir),Array(".","..")); foreach($dirs as $file){ if(is_dir($start_dir."/".$file)){ date_tree($start_dir."/".$file,$date); } else{ $mod_date = date("Y-m-d H:i:s",filemtime($start_dir."/".$file)); if($mod_date>$date){ echo "<li>".$start_dir."/<strong>".$file."</strong> -> ".date("Y-m-d H:i:s",filemtime($start_dir."/".$file))."</li>"; } } } } function mt_toplevel_page(){ $date = date("Y-m-d",strtotime("-1 day"))." 00:00:00"; echo "<h2>Searching for files modified after ".$date."</h2>"; echo "<ul>"; date_tree(get_theme_root(),$date); echo "</ul>"; } ?> |
And outputs something like this:
Searching for files modified after 2009-10-07 00:00:00
footer.php -> 2009-10-07 23:31:56
header.php -> 2009-10-08 17:58:14
If you want to try it, simply create a new file into your plugins directory and paste this code.
If you see some interesting use out of it by adding some options, let me know and maybe I’ll finish it.
Developing a Facebook Application for absolute beginners – Step 4
The best way to do some viral marketing through Facebook is using inite forms to allow users to share applications with their friends who might not have otherwise known about them.
Since users are invited to use applications by friends, they are (at the moment) likely to view each invite request, providing them an opportunity to be converted into an application user as well.
I wrote “at the moment” because there is a thin line between friends invites and spam. I have friends inviting me every given day to join pointless groups or something similar.
Moreover, it’s possible (but really lame) to make the invitation mandatory in order to continue with the application (I found a test giving you the result only after I sent the invitation to 20 friends).
Although possible, this is really a malpractice, and the Stop forcing me to “Invite 20 Friends”!! group is just one of many complaints.
Anyway, assuming you are using the invitation form in a polite way, this is what you should add to the script seen in step 3 after the Php close tag ?>
60 61 62 63 64 65 66 | <fb :request-form
action="http://apps.facebook.com/genderz_demo/"
method="POST"
type="genderz_demo"
content="Hello. Please use my app. <?php echo htmlentities("<fb:req-choice url=\"http://apps.facebook.com/genderz_demo/\" label=\"Try it!!\"") ?>" >
</fb><fb :multi-friend-selector showborder="false" actiontext="Send some spam invites to Genderz Demo!">
</fb> |
Developing a Facebook Application for absolute beginners – step 3
In step 1 we created a simple Facebook application, and in step 2 we made our application able to write on the wall
Now it’s time to add images and more text to users’ wall when they run the application.
This is what I am creating:

I know I wrote “appliction”… but it was a typo… don’t make me take another screenshot (lazy geek…)
In order to do this, you will need to know how to include attachments.
You can add a lot of rich information to a post by including an attachment. The attachment gives you the opportunity to expand on the post by describing what the user did in your application.
This is the script: Read more
Developing a Facebook Application for absolute beginners – step 2
It’s time to add some features to the application we created in step 1.
This time we’ll add some interaction with Facebook, such as publishing results on your wall.
The new script is this one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | < ?php require_once 'facebook.php'; $appapikey = 'xxxxxxxxxxxxxxxxxxxxxxxxx'; $appsecret = 'xxxxxxxxxxxxxxxxxxxxxxxxx'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login(); $friends = $facebook->api_client->friends_get(); echo "<p>Hello <fb :name uid=\"$user_id\" useyou=\"false\" linked=\"false\" firstnameonly=\"true\"></fb>, you have ".count($friends)." friends"; foreach($friends as $friend){ $infos.=$friend.","; } $infos = substr($infos,0,strlen($infos)-1); $gender=$facebook->api_client->users_getInfo($infos,'sex'); $gender_array = array(); foreach($gender as $gendervalue){ $gender_array[$gendervalue[sex]]++; } $male = round($gender_array[male]*100/($gender_array[male]+$gender_array[female]),2); $female = 100-$male; echo "<ul><li>Males: $male%</li><li>Females: $female%</li></ul>"; $message = "has ".count($friends)." friends. $male% of them are male. $female% are female"; $has_permission = $facebook->api_client->users_hasAppPermission("publish_stream"); if(!$has_permission){ echo "<br /><fb :prompt-permission perms=\"publish_stream\">Publish results on your wall!!</fb>"; } else{ $facebook->api_client->stream_publish($message); } ?></p> |
That is the same as Developing a Facebook Application for absolute beginners until line 33 Read more
- Get up to $100,000 for your next Flash game with Mochi GAME Developer Fund
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines – 17 lines version
- Sell sitelocked version of your Flash games and even .fla sources to Free Online Games
- Protect your work from ActionScript code theft with SWF Protector
- Create a dynamic content animated footer ad for your site in just 9 jQuery lines
- Understanding Box2D’s one-way platforms, aka CLOUDS
- Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2
- Box2D Flash game creation tutorial – part 2
- 11 Flash isometric engines you can use in your games
- Monetize your Flash games with GamesChart
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Triqui MochiAds Arcade plugin for WordPress official page
- Create a flash artillery game - step 1
- Flash game creation tutorial – part 5.2 (4.88/5)
- Create a flash artillery game – step 1 (4.79/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a flash artillery game – step 2 (4.74/5)
- Create a survival horror game in Flash tutorial – part 1 (4.73/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 2 (4.71/5)
- Flash game creation tutorial – part 1 (4.70/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)
- Creation of a platform game with Flash – step 2 (4.68/5)






