Hi there!
Quite a while ago, I started writing my first and own facebook application. I got stuck while trying to publish content to my own profile page and also to my friends’ newsfeeds. I stumbled upon several problems. Either there was no content displayed, it was formatted in a wrong way, it was not published on my friends’ newsfeeds or it even was published on behalf of my friends’ username. It was quite strange to me and I could not find an easy documentation on how to do it the right way.
I played around with Stream.publish, Feed.publishUserAction or Notifications.send – none of those functions did what I wanted them to do. This may be so, because I did not fully understand their purposes.
So, this is my way to do it. I am using the FBJS (FaceBook JavaScript) popup call Facebook.showFeedDialog. This is truely (as far as I’m concerned) the best and easiest way.
First of all, I assume you are familiar with how to build an facebook application from scratch. If not, please read the developer’s documentation.
Step 1: build and register your Feed Template Bundle
- go to the Feed Template Console
- choose your application and hit “Next”
- create a template for your “One Line Story” and hit “Next”
- create a template for your “Short Story” and hit “Next”
- create Action Links and hit “Next”
- hit “Register Template Bundle”
- copy and save the Template Bundle ID given in the popup (you will have to paste it into your application’s code later)
When doing this, you may enter any text or even HyperText in the fields for the One Line or Short Story. You also may enter predefined tags such as {*actor*}
or your own defined tags such as {*foobar*}
. In the Sample Template Data, you may enter the tag definitions and display a preview. What you enter there and at this very moment has no effect on the content displayed within your application later! That’s just for previewing purposes. The real content will be defined later in your application’s script. Remember that! Some Examples for your Sample Template Data at this point may be:
{"foobar": "This is a foobar text"}
Or a bit more complex:
{"foolink": "<a href="http://www.google.com/">Google</a>",</p> <p>"images":[{"src":"http://domain.com/image1.jpg", "href":"<a href="http://www.facebook.com/">http://www.facebook.com</a>"},</p> <p>{"src": "http://anotherdomain.com/image2.jpg", "href":"<a href="http://www.facebook.com/">http://www.facebook.com</a>"}]}
You see, e.g . the {*images*}
tag is defined as some sort of array consisting of multiple SRC and HREF values. Attention: the special tag {*images*}
is displayed automatically on Short Stories, you don’t need to call them!
2. write your application’s content
<?PHP</p> <p>require_once 'facebook-platform/php/facebook.php';</p> <p>$appid = 'xxxxxxxxx'; // your app ID</p> <p>$appapikey = 'XXXXXXXXXXXXXXXX; // your app key</p> <p>$appsecret = 'XXXXXXXXXXXXXXXX'; // your app secret</p> <p>$template_bundle_id = 'xxxxxxxxxxxxxxxx'; // the ID you got in Step 1</p> <p>$facebook = new Facebook($appapikey, $appsecret);</p> <p>$user_id = $facebook->require_login();</p> <p>echo "<p>Hello, <fb:name uid=\"$user_id\" useyou=\"false\" />!</p>";</p> <p>?></p> <p><script type="text/javascript"><!--</p> <p> var template_bundle_id ="";</p> <p> var url="http://www.google.com/";</p> <p> var user_message_prompt = "Share this URL with your friends?";</p> <p> var user_message = {value: "wants to share a greate website."};</p> <p> var image ="http://www.google.com/intl/en_ALL/images/logo.gif";</p> <p> var template_data = {"url": url,</p> <p> "images": [{'href': url, 'src' : image}]};</p> <p> Facebook.showFeedDialog(template_bundle_id, template_data, '', '', '', user_message_prompt, user_message);</p> <p>// --></script></p> <p>
This is it.
Every time you call your application’s page, you’ll get a facebook popup asking you to display the content on your profile and even in your friends’ newsfeeds. Of course, it does not make any sense to share some data every time you call your application’s canvas page, so you may want to add some more code to your application.
The text to be shared is the text you entered when registering the Template Bundle in Step 1. If you get an error, please make sure the defined variables (such as “url” or “images”) are valid and do exist. In other words: whatever you call in your Template Bundle, it has to be defined in your script.
Of course, you may generate the content dynamically from a database or any other source.
I hope this HOWTO helped.
Bye, T.
Hi there,
after several months, unfake.it has become even more important in the Web2.0 community. A few weeks ago, I was talking to some guys and co-workers about programming and such things. I then told about unfake.it and a co-worker of mine said, he somehow stubled upon http://unfake.it/ and uses it irregular. That was quite funny to me.
I’ve had very few time the past months and since I got stuck on the half way because of some WordPress problems and also some problems with facebook’s API and FBML, there was no more development. But now I’m proud to announce that today, I released a completely new version including new features:
WordPress plugin version 1.2
The new plugin comes with its own settings page and adds two own tables to your WordPress installation. The main purpose is to let you configure, whether or not you wish to be taken to facebook and add the shortened URL for your new blog post (including a thumbnailed screenshot) to your facebook profile page and even in your friends newsfeeds.
Facebook application
unfake.it now has its own facebook application which lets you add shortened URLs, lists them as screenshots in a profile box, displays about new URLs on your profile wall and even tells your friends about it in their newsfeeds. Want an example? See:
Since a few hundred URLs are shortened every single day, I also had to do some enhancements to the database structure and especially to the thumbnailing process. Just think about it: at the moment, we have more than 20,000 shortened URLs, each of them was once and initially thumbnailed, stored and is re-fetched every few days, if still hits occur. That’s a lot of traffic and a lot of CPU power. Just take a look how MySQL handlers and Apache traffic increased the last months:
You may see most recent stats at http://unfake.it/stats.php.
Please let me know, if you have any problems with the new version of the WordPress plugin and especially what you think about the facebook application.
Bye, T.
Hi there!
Do you know this problem?! You have to get up at some certain time in the morning, so you set up your alarm clock to give you a friendly “rrrrrrring-rrrrring”. But you simply don’t wake up! Your alarm clock rings and rings and rings for like hours but you simply don’t hear it. Sometimes, you use the snooze button, but you cannot even remember you did it.
Well, that’s like how I feel sometimes in the morning. Bad thing, if you have some kind of meeting or appointment. Several times in the past, I sent automated e-mails to my co-workers to give me a wakeup call on my cellphone, this surprisingly always works. But it’s annoying. For me and my co-workers.
Here comes the solution:
use nagios to give you a highly sophisticated wakeup call.
Imagine, you have a linux box which is under surveillance of a nagios remote monitoring system. And imagine furthermore, this nagios system is configured to send out voice calls in cases of critical states. All you need is a new plugin (most commonly via NRPE) which tells nagios to initiate your wakeup call.
This is how I do it:
1. Add the following line to your NRPE config file on your linux box (e. g. /etc/nagios/nrpe.cfg
):
command[wakeupcall]=/usr/lib/nagios/plugins/wakeupcall
2. Create the plugin and place it on your linux box at /usr/lib/nagios/plugins/wakeupcall
#!/bin/bash # # nagios nrpe plugin to initiate a wakeup call # 2009, Thomas Gericke, thomas (at) thomasgericke (dot) de # FILE="/etc/wakeupcall/wakeupcall" if [ -e $FILE ]; then echo "Wakeupcall needed. Gonna hit ya!" exit 2 else echo "No wakeupcall needed. Sleep well." exit 0 fi
3. Restart your NRPE service on your linux box (e. g. /etc/init.d/nagios-nrpe-server restart
)
4. Set up the service check in your nagios configuration on your nagios server
I assume, you already have the host configured on your nagios system and you already are familiar with nagios’ notifications. Here’s the service check you need:
define service { use generic-service max_check_attempts 1 notification_options c service_description Wakeup Call host_name YOUR.HOST.NAME check_command check_nrpe!wakeupcall contact_groups YOUR_CONTACT_GROUP }
I hope you’re familiar with nagios’ service check templates and such stuff.
5. Reload your nagios on your nagios server (e. g. /etc/init.d/nagios reload
)
6. Create the wakeupcall config directory on your linux box (mkdir /etc/wakeupcall/
)
7. Set up a file for an at-job on your linux box (e. g. ~/add.wakeupcall
)
touch /etc/wakeupcall/wakeupcall
8. Set up an at-job on your linux box once you need to be woken up
at -f ~/add.wakeupcall 06:40
Your linux box will create /etc/wakeupcall/wakeupcall
at 6.40AM (the very next time this moment occurs), nagios will realize it and will initiate the notification. If you have configured your nagios server to send out voice calls to your cellphone, you will receive a wakeup call.
Have fun, comments are appreciated! 🙂
Hi there!
Do you use facebook and facebook’s chat function once in a while? Yes? And do you know Digsby? No? Not yet?! Well, you should!
I used to use Trillian as Instant Messaging client like for years, but last autumn, I switched to Digsby: http://www.digsby.org/.
It’s a high performant IM client with lots of features and (that’s what I like most about Digsby!) some great Web 2.0 implementations.
I guess, some of you might use facebook’s chat function. So did I but I did not like it that much. It totally wrecked my nerves to use my webbrowser for a chat. You may know the tiny little conversation windows as it appears on the very bottom of your browser tab. And that’s (at least for me) the first problem: conversations are bound to exactly this browser and this tab.
If I open facebook’s website at work and forget to close the browser or the tab before I leave for home, I appear as online to all my friends, they write me and wonder, why I don’t reply – even if I’m online at home, but did not check into facebook’s website.
It might be a great function – but I really don’t like it. I’m used to certain applications for instant messaging. Such as Digsby.
Digsby has even more than a full Web 2.0 integration – you may use this IM client as a fully compatible and realtime instant messanger for facebook. Simply check “Tools” in the applications menu, then “Preferences”, then hit “Add IM Account” and select “Facebook Chat”.
Once you entered your correct account data, your online facebook friends will appear in Digsby’s Buddy List – right between your Buddies from ICQ, MSN, Jabber, …
And this really is realtime. I noticed no lag so far. The sign-on and sign-off popups even show your friends most recent status, which turned out to be very usefull for me. This is how I noticed, one of my facebook friends had a BBQ yesterday, so I could join 🙂
Once you double click one of your friends in your Buddy List, a conversation window opens – just like every IM client should behave.
You may also use the shortcuts to your friend’s profile, wall, photos and so on. Check out the following screenshots:
For me, this is a very useful IM integration. Check it out! 🙂
Bye, T.
Hi there!
I have to thank you! All of you, using unfake.it as URL shortening service!
It’s been 100 days, since I faked the first URL with unfake.it – my very own URL shortening service. I started this project, ’cause I always forgot the names of all the other URL shortening providers, so I very quickly wrote my own application, which now is used every day by lots of users.
What began for my personal use only, has now become a huge and important project. A few days after the initial launch – and even without heavy announcement, the first people started using unfake.it to shorten URLs. Using the bookmarklet, some friends and co-workers started using unfake.it and spreading the URL all over the world.
Then, I implemented an API and wrote a standalone WordPress plugin to shorten URLs for new blog postings before sending them to Twitter. Since March, this plugin is downloaded and installed on new WordPress blogs almost every day a couple of times, which really makes me proud. Today, several co-workers as well as absolutely unknown users all over the globe are using my plugin. And there’s an huge number of hits per day:
Then, I implemented the magic preview function with thumbnailed images of the destination websites. Then I wrote a facebook application to add faked URLs and their thumbnails to your facebook profile. Those are just toy-like features, but I relly like them – as well as lots of users.
Some facts of what has happened so far (or is happening):
- more than 3.000 URLs have been faked up to now
- there are more than 42.000 hits to those URLs up to now
- the last 3 days, more than 100 new URLs have been added per day
- URLs for more than 130 unique websites have been faked up to now
- the WordPress plugin has been downloaded and most likely installed more than 80 times
- Twitter knows more than 850 faked URLs of the last 7 days
- Google knows more than 20 pages of faked URLs
- unfake.it is growing every day
I’m really looking forward to unfake.it‘s future. Sure, there is an increasing number of shortening services, but I guess, some of ’em will disappear again.
Bye, T.
Hi there!
This totally makes me sick. About a week ago, I renewed my contract with t-mobile and got an upgrade from my old iPhone to a new 3G iPhone with 16GB memory. Well, nice, nice.
I was told, the “old” contract would be cancelled within the next few days and the new contract would begin right after the other one stopped. But the new phone would work instantly with the old card. Well, and it did. Everything worked quite fine.
Just until last Sunday, 2009-04-12. On Sunday, my iPhone told me for the very first time: “Could not active cellular data network
“. Well, at first I thought there might be just a coverage problem. Then I remembered, the contract needed to be switched and maybe there would be a short service outage.
Then I forgot about the problem for a while. Until today. I tried data networking and it didn’t work. So I called the service this evening.
There’s one number burned in the very back of my brain. It’s the T-Com service hotline:
+49 800 33 0 1000
I called this number and all the fun began. This hotline is voice-guided, which always makes me very, very happy. You can shout from the deepest point of your lungs to this conversation partner and she will never ever be mad about it.
She asked me, what my call was about. I said: “INCIDENT!”
She did not understand.
I shouted: “OPERATOR!”.
Well, she agreed to connect me with an operator but she first needed my phone number. After I told her my number, she said: “This is a cell phone number. I need a land line number.”
Just as I was about to destroy everything I could reach with my free arm, she said: “If you don’t have any number, just say ‘next’.”
“Hell, next. Neeeext! N – E – X – T !!!”
“Please be patient, the next operator is reserved for you”, she said and I smiled. Nice, nice. BUT: after 16 (sixteen!)
minutes, a male voice said: “All operators are busy. Please call again later.” *Click*
What the hell?! Okay, okay. I remained totally calm (will clean up the broken dishes later… [just kiddin’]) and called the same number again. “Incident. *ARGH* OPERATOR! NEXT!” And I got connected to a women within less than one minute.
I told her about my problem and after she listened about 2 minutes to my hole story, she said: “You have to call T-Mobile, there’s the number 01805 …”
“Stop!” I said. “I definitely WILL NOT call a service number which is NOT toll-free.”
I could see her shocking face on my iPhone as she searched on her computer and finally found another number, which I immediately called:
+49 800 88 55 400
Funny thing: the man who answered was responsible for DSL and leased lines and had absolutely no idea about cellular networking. But he agreed to pass me on… to his manager or whatever. And this funny person told me to call the toll-free cell phone service number:
2202
Well, I called this number. Three times in 5 minutes!
The first guy told me to active the Airplane Mode. As I told him “but this will interrupt our call”, he said: “no, no, we will stay connected, I know this for sure!” Oh my God, what a freak. As I tapped the “Airplane Mode” button, my iPhone said — guess what — “this will interrupt your current call”. Well, ehm… eh?
He then told me to quit the call and to this Airplane-Mode thing. Cellular data networking should work after that. I tried and — surprise! — it dit NOT work!
I called the same number again, told the hole story to another guy and just as I was about to ask what to do now, the connection was terminated. What the hell?!
So, I called the same number again a third time and told the story again. It was someone with a foreign accent, but he was totally okay. He asked me to stay connected, he would talk to an iPhone expert. After about 5 minutes, he came back and asked if I ever tried to turn the device off and on again. OMG! Sure I tried it several times. He again talked to the iPhone expert. As he came back to me, he had no further idea.
His suggestion was to call back tomorrow at 8am to get directly connected to an iPhone technician. I agreed to that.
But I could not believe, this problem to be that unique. So, I googled for “could not activate cellular data network” and the very first link was. http://unfake.it/c4l
One guy posted, he simply reset his networking settings (Settings -> General -> Reset -> Reset Network Settings). So, I tried this. And — TADA! — it works perfectly again.
My conclusion: T-Mobile should use Google as knowledge-base
.
Hi there!
English //
German
I have the very first iPhone, bought on 2007-11-09 in an T-Com store. Now, the display ain’t working correctly anymore. //
Ich habe das allererste iPhone, gekauft am 2007-11-09 in einem T-Com Laden. Jetzt funktioniert das Display nicht mehr korrekt.
The device did not fell down, I did not hit it anywhere. I just put it in my pocket at work and as I got home, the lower centimeter of the display ain’t working anymore. //
Das Gerät ist nicht herunter gefallen, ich habe es auch nirgendwo angehauen. Ich habe es auf der Arbeit in meine Tasche gesteckt und als ich heim kam, funktionierte der untere Zentimeter des Display nicht mehr richtig.
This unfortunately includes the buttons “Phone”, “Mail”, “Safari”, “iPod” and – of course – the lower buttons in each application. The 90% of the display do work absolutely correct. //
Dazu gehören leider auch die Buttons “Phone”, “Mail”, “Safari”, “iPod” und – natürlich – auch die unteren Buttons aller Anwendungen. Die oberen 90% des Display funktionieren einwandfrei.
I know, my iPhone ran out of warranty, but it’s very obviously a well known hardware failure, which occurs quite often. //
Ich weiss, dass mein iPhone bereits aus der Garantie gelaufen ist, allerdings ist das sehr offensichtlich ein Hardware-Fehler, welcher durchaus recht oft auftritt.
I found several websites and forums about that: //
Ich habe darüber einige Webseiten und Foren gefunden:
- http://unfake.it/GzR (german forum
//
deutsches Forum) - http://unfake.it/VVL (german forum
//
deutsches Forum) - http://unfake.it/Q4E (english website
//
englische Webseite) - http://unfake.it/0S3 (english website
//
englische Webseite)
The last one is probably the most important and interesting one. Quotation: //
Der letzte Link ist wahrscheinlich der wichtigsten und interessanteste Link. Zitat:
“First the very bottom of the screen went out so I could not hit the space-bar on the keyboard, or change to the number/character screen. Then it got worse a few days later, now I cannot hit any of the main function buttons.”
This is proof enough for me. It must be a hardware failure and must have its origin in the fabrication. //
Das ist Beweis genug für mich. Es muss sich um einen Hardware-Fehler handeln und dieser muss seinen Ursprung bereits in der Herstellung haben.
Now, I will print out those websites and I will confront T-Com in a store with those fact the next few days. I simply don’t want to pay for a new display, ’cause it’s really expensive. //
Nun werde ich diese Webseiten ausdrucken und die Telekom in einem Laden mit den Fakten konfrontieren. Ich möchte einfach nicht für ein neues Display bezahlen, da das wirklich ziemlich teuer ist.
Does anyone have some more tips? //
Hat noch jemand gute Tipps?
T.
Hi there!
A few days ago, I started to write my first own facebook application. It all went quite okay until one certain point: I wanted my application to update the profile box of the user, which uses the app at that single moment. And that wasn’t as easy, as I thought.
The problem was: after the profile box has been updated, all profile boxes of all users had the same content – the content of the user who last updated his profile box.
I will come to the solution later. First of all, a quick explanation of what I needed to do:
- I read the documentation of facebook’s application guide to understand the API and the FBML language
- I set up my own application using the step-by-step guide
- I set up my new application on my own host including facebook’s PHP libraries
Here’s the code step-by-step (just put all sniplets together):
Code sniplet #1
require_once 'facebook-platform/php/facebook.php'; $appid = 'xxxxxxxxxxxx'; $appapikey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $appsecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login();
Above: first of all, we need to include facebook’s PHP libraries, define several variables for our application, initialize our facebook object and retrieve the UID of the user who currently uses the application.
Code sniplet #2
$fb_box = "<H4 class='box_header clearfix'><span>"; $fb_box .= "Hello World!"; $fb_box .= "</span></H4>"; $fb_box .= "<div>I am "; $fb_box .= "<fb:name uid=\"$user_id\" useyou=\"false\" />."; $fb_box .= "Nice you're on my page.</div>"; $fb_box .= "Some more content in HTML or FBML...";
Above: we then define the content which we want to be displayed within the profile box. In this examble, it will be the name of the user, greeting the visitor.
Code sniplet #3
$fb_box_handle = 'pb_' . $appid . '_' . $user_id;
Above: this is important! At this point, I got stuck for a while. The reason was, facebook caches profile boxes content until the application’s canvas page is requested for the next time. The handle is very important for that caching mechanism, since it has to be a unique identifier for each application and each user. For that reason, I simply use the prefix ‘pb_‘ followed by the applications ID (defined above) and the UID of the current user (also defined above)!
Code sniplet #4
$facebook->api_client->call_method('facebook.profile.setFBML', array( 'api_key' => $appapikey, 'v' => '1.0', 'uid' => $user_id, 'profile' => '<fb:narrow><fb:ref handle="' . $fb_box_handle . '" /></fb:narrow>', 'profile_main' => '<fb:ref handle="' . $fb_box_handle . '" />', ) );
Above: the rest is quite simple. We make an API call to facebook and send our application key, the protocol version, the UID of the facebook user whose profile box ought to be updated and, of course, the content for that box. The content will be sent as the reference handle we defined earlier.
If you want to update multiple profile boxes with one single API call, I guess, this could work if you send an array containing the UIDs. If not, you can still get all those UIDs, walk through the array and perform multiple API calls. I read somewhere, some users had problem updating large numbers of profiles… Just give it a try.
Comments (if it worked for you or even if it didn’t) are appreciated 🙂
UPDATE because of comment #2:
The example above is about updating content in a users profile, not about setting up a profile box on a profile. You should read the manual carefully.
A user has to approve a certain application to create a profile box. Therefore, you need to render a button, which sets up the box. You can easily do this by:
$appapikey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $appsecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login(); $facebook->api_client->profile_setFBML($appapikey, $user_id, 'profile', NULL, 'mobile_profile', 'profile_main'); echo "<fb:add-section-button section='profile' />";
The last line renders the button, you want to have on your canvas page.
Good luck! Thomas
Hi there!
As some users reported, they would not like the dark style of the unfake.it
website, you may now choose between a dark and a bright style.
Besides the possibility to choose between a dark and a bright style, you may also set the site’s language. unfake.it
is currently available in English and German.
Your preferences will be set as a cookies, so you do have to allow cookies from unfake.it
. As long as you did not set any preference, the dark style and English language will be default.
Hi there!
unfake.it
has become a new and standalone plugin for WordPress!
Alex King (thanks for that!) just added filter hooks to his famous Twitter Tools plugin for WordPress, which allows everyone to push URLs for a new posting to a filter. In this case, the unfake.it
URL shortener for Twitter Tools takes the URL, shortens it and gives it back to Twitter Tools before notifying Twitter about the new post.
Usage is quite simple, no configuration is needed. This plugin just depends on Twitter Tools version 1.6 (or above). If you install unfake.it
URL shortener without having Twitter Tools installed, simply nothing will happen. Your WordPress blog won’t be affected in any way.
Plugin URL, download and documentation here: http://unfake.it/help.php#twitter-tools
New project for the WordPress plugin directory is pending and assumed to be online soon.
So, all of you using Twitter Tools and already my patch for it: you should upgrade to Twitter Tools version 1.6 and also install the new unfake.it
URL shortener plugin in addition to Twitter Tools.
Please let me know whether you experience any problems.