How are real time updates in Facebook, Twitter and Google Plus performed - real-time

When I try to implement a real time update system on my site, I usually make an ajax call, say every 5 secs to a processing file, say getUpdates.php (not sure if it's the right way to do). Get the updates from there and display it. Doing that, when I look at firebug or the developer tools in Chrome and Safari, I can see the file being called ever 5 secs in the XHR section of the tool; after which the updates are displayed.
In case of Google plus, twitter and Facebook, I don't see such a regular call although updates are appearing right in front of me.
How is it that they are doing or is it me not noticing such a regular call??

They use "Long polling" I think. Sounds like a fine excuse to dabble with node js if you ask me. :)

Related

Testing Facebook Messenger Scan Code

Facebook recently announced the introduction of messenger codes which can be used to add new contacts and, more importantly, communicate directly with businesses and business pages (which is why I'm interested in it).
It took me ages to find it but on the bottom left of the messages tab on my Facebook page I have the option to download my code in three different sizes - clicking the disc will open a modal window where you can click the Download button and choose from 300, 600 or 1000px PNG file downloads.
NOTE: While they are PNG files the background is not transparent which seems like a bit of an oversight to me but hey ho that's what Photoshop is for I guess.
The problem is that while I can download my code I can't find any way to test it on printed materials (or even electronically at the moment!). The scanning feature doesn't seem to have been rolled out for me yet (I tried re-installing the Messenger app to see if I got a newer version but that didn't work) and nor for anyone I know (I'm in the UK). The codes are bespoke to Messenger so can't be scanned or tested using any other app.
I'm probably too far ahead of the game but is there any way I can test to see if my code scans correctly, or anywhere I can go to find out? I would like to use it on some promotional material which is likely to be long term materials that I don't want to have to update in the near future (several years, by which time it's likely these codes will be more commonplace).
I also need to know what the redundancy is like. For example the high redundancy QR codes I generate can have up to 30% of the code covered while still being usable, which is great for design purposes. I can't find any official documentation as yet for these codes at all, let alone what is required, what the spec. is etc.
I know the most likely option is 'sit and wait' but I really would rather not if possible. I've never been very patient...
Thanks
UPDATE: My Messenger app has now been updated so I can test, but I'm leaving this here in case anyone knows of another way to test perhaps? If someone doesn't have Messenger on their phone for example.

can i use a generic app id for multiple websites' like boxes

I am going insane with this. It used to just work! I'm a programmer but not up to date with all this modern languages stuff and have no desire to learn it - too darn old, just want an easy life.
Okay, so here's the thing... I used to have these "like boxes" on my websites. Then they stopped working. I looked in the dev docs and fixed the absolute URL and they worked ok on IE browsers but not on Chrome.
It looks like I need an App Id.
So I created an App Id on a test website - I have no idea what it is or why I need one. All I want to do is show on the website it has n likes and the button for Facebook lovers to like it too.
But do I need to create an App Id for every single clients website? How do other CMS systems handle it? My sites are not html 5 - I'd be happy with just an iframe solution.
I'm not a fan of Facebook at all, and this is driving me further away. I'm willing to be dragged back but all I see is lots of overly complex code to achieve nothing really useful.
You can do whatever you want with your app ID, but if you use the same one for all your sites, you won't be able to separate those in your "Insights"
https://www.facebook.com/insights/

Can Facebook/Google cause site to not load?

This might sound like a silly question, but yesterday none of our sites would load. After contacting the hosting company they said that
In this instance, it would appear that your site is hanging waiting for a response from an external component / website (looking at your code, I see references to Facebook, Google and online apps at a glance).
We've never had this problem before and the sites have been using the social plugins for months so I wondered if anybody else experienced this problem yesterday?
Thanks
Without knowing the details, I can tell you that when you load Javascript via <script></script> tags the browser waits for the request to finish before moving on. So, if you load JS files in the <head></head> section, nothing will render on-screen until they load successfully. 404s here will kill you, as will slow connections.
If you have in-line JS, it's best to put it at the very bottom of your <body></body> section so that it does not interrupt browser rendering. Do this for JS files in your <head></head> section if your code architecture allows it.
Just a random stab in the dark but I wonder if this was related in any way to the anonymous threats on Facebook. I have experienced similar problems before with a twitter plugin, it could take a few seconds for the plugin to ping back the tweets and the rest of the page was hanging while twitter was doing their thing.
To ensure this doesn't happen again you could call your social plugin's on page load if its a viable solution. At the end of the day do you want your page load time to depend on other services outside of your control or not?
edit: #Jason McClellan 's answer is spot on. I believe the combo of out answers sort out your question. I Never include script in the head if I don't control the resource! That can indefinitely hang your page.
edit2: Don't know why I'm getting down rated for this answer was just trying to relate it to an experience of mine. I'm not extremely experienced with Facebook plugins but when I was noticing an issue with my twitter plugin, I did exactly what #Jason McClellan has said with his answer to make sure that all your html gets rendered before the scripts are even requested, then ensured that the page could display correctly with or without the twitter content so the user experience was not dependant on an external resource. The twitter plugin I was using had an initiation function which I had to call to fire up the script. The simplest way to call this would be with:
<body onload='init()'>
if you have another script you are loading with the page you could use something along the lines of
window.onload = function() {
init();
}
from within your external script.
Sorry I can't give an answer specific to the Facebook plugin. Maybe someone with more experience in the Facebook plugins could elaborate in the comments :D
edit3: also this community based tool suggests that quiet a few people where seeing a bit of facebook downtime when you experienced it - Facebook status at DownRightNow
edit4: I dont have the "Privelages" to comment on Jason's q as im pretty new here ... but in answer to your comment there, the stuff in the head that you describe is what loads in the schema for facebook mark-up language (fbml) , so a mark-up language like html, but geared up for you to use the facebook api. So you can do stuff like:
<fb:comments xid="titans_comments" canpost="true" candelete="false" returnurl="http://apps.facebook.com/myapp/titans/">
<fb:title>Talk about the Titans</fb:title>
</fb:comments>
To wack some comments straight into your page - fbml developers guide
Your comment there also suggests you are not including a script for your page to load so it renders our previous answers not as important, you need to include the fbml stuff in the head before you use fbml in your page so don't move it :D
but #jason McClellan's answer is something that everyone should do on their project (unless there is a reason not to) as it allows for the user to see something before the browser fires off requests for the scripts. At the end of the day we're in this game to make pretty stuff for our users!
Good luck

Up to date instructions for September 2011 onwards for beginners

Sorry for this basic question but all attempts at Googling and using facebook help only provide out of date information.
I am attempting to make my first fb app. Just an html page saying hello. From what I understand the app (or webpage) is stored on my server and I set up a facebook app that basically points to the URL of the app (or webpage) on my server.
Is this basically correct.
Where do I enter this URL information in my edit app screen. I have followed the latest fb instructions and all I see when I view the app is the admin page in fb for the app.
Does it take a long time for the page to appear.
Is there a current idiots guide. The app design is not a problem for me loading it in to facebook is the problem.
Unfortunately this wasn't very helpful, not because of what you posted but due to the fact that it appears that Facebook has updated the way in which pages are linked to again.
The pages you suggested I look at were well laid out with lots of information on them but they are already out of date and do not seem to correspond with the layout of the Facebook 'dev app' and even the fields in the form seem to have been either dropped added to renamed.
Thanks for trying to help me and I hope that FB may produce some up to date information soon and not keep changing the interface.
I can completely understand your confusion - the Facebook docs give very little information for the complete beginner. The 'Getting Started' section makes some massive assumptions and completely ignores huge key areas you need to know to get your first application up and running.
So to address your points:
Yes, this is basically correct. Apps on Facebook are served up to the user in one of two ways. Either as a 'Canvas App' or a 'Tab App'. A Tab App is an application you can install as a tab on a profile page. A Canvas App can operate on it's own page and has more room as there's no left menu as you would have on a profile page. You can configure a single app to work in both ways.
To edit your application settings, go to your own Facebook home page. Use the search bar to search for the 'Developer App'. Typing in 'developer' should do it - it should be the first result in the App section with around 830,000 monthly users. This Developer app is the window into your own app settings. You need to install it if you haven't already. It's a hub where all the apps you create will be available for you to edit. Whenever you want to edit one of your app settings in future, you click the Developer bookmark that will now be in the left menu on your own Facebook home page.
No. Apps are basically an iframe onto your code. There should be very little if any wait at all. Start with something very simple like spitting out some straight html so you can easily tell if things are set up correctly.
Yes. I found thinkdiff.net to be massively useful in the early days to get my head round the basics and then more advanced concepts. There's tons of examples ranging from very simple to quite advanced. I've just had a quick look around and found this page which should give you a decent head start in getting things moving. Note: I have no affiliation with thinkdiff.net at all - I just found them helpful in the past.
Finally, a request from me; this whole stack overflow thing is new for Facebook developers and very few people are voting up answers they consider helpful. This means new users to SO but experienced FB developers can't vote up good answers and vote down bad ones as we need enough Reputation Points to do so. If this has helped you, please ensure you vote up the answer. Of course if it was rubbish and you're just as lost, dont :D
Hope I've helped in some small way; I know I was completely lost for the first few weeks with FB development and even now there are things that make me tear my hair out! In the end it's very rewarding, but you have to put in the time. Good luck :)

I want to be able to search an html page that is refreshing every 10 seconds for the word "stat"

I want to be able to search an html page that is refreshing every 10 seconds for the word "stat". If the word is found I then want to alert the user through a pop up dialog and possibly a repeating sound until the user acknowledges it.
UPDATE:
Sorry the question was a bit ambiguous. I do not know a great deal about this stuff I just do it as a hobby.
OK so here is the deal. I work as Biomedical Electronics Technician for a hospital. We have a work order system that is web based. Nurses can enter a work order into this system. I have a browser window open at all times that refreshes periodically through an add-on for IE so I can always be up to date on the status of the work orders coming in. When a nurse the enters enters a work order they have the option of choosing Stat, High, Medium, or Low for the priority. When a stat work order is placed our response time should be within five minutes theoretically. I want some way to alert myself when a stat work order has been placed so I can respond accordingly. And I know a repeating sound would be annoying, but that might be the best way to get my attention.
Another caveat to this is the work order status can be changed by me, the tech. So when a work order is initially placed the status is Not assigned or something like that. Once I go start on a work order I change the status to In Progress. If I have to order a part I change the status to Hold for Parts, etc. So basically, what I am saying is I don't want to alerted if the status is anything but "Not assigned". If it will help I will get a copy of the source of the page when I get to work tomorrow.
Our IT department seems unwilling to help and the company that made the product is so busy chasing the daily bugs that show up to add new features such as this at this time. If I knew more a Google search might help, but alas I am a bit noobish in the programming realm, however I am 2 years from a C.S. degree so I am not a complete novice.
To answer another question, I do not have access to the page I am just viewing it so any sort of script would need to run on my client machine.
Thanks
I found this, try it https://addons.mozilla.org/en-US/firefox/addon/3028/
Maybe it can search for STAT on the entire page?
Based off your description, it doesn't sound like you have access to the server to change the code of the page itself, correct?
If that's the case, spend some time learning how to use Greasemonkey (or rather Greasemonkey for IE). It allows you to add functionality to a web page from the client (browser) side, regardless of what's on the server.
You'll need to find the elements that hold the "stat" term your after, and have it check periodically those elements periodically. Look into the setTimeout method for that periodicity. The rest you'll have to work out specific to that page.
What you're looking for, since you have python available, is to build a simple, easy to use webscraper.
First link is how i would do it quick and dirty.
http://www.ehow.com/how_4436125_read-web-page-using-python.html
Second link is a bit more robust and nifty with BeautifulSoup
http://www.builderau.com.au/program/python/soa/Build-a-basic-Web-scraper-in-Python/0,2000064084,339281476,00.htm
Basically, read the page (even set the whole loop on a 10 second refresh timer).
Go line by line with a while readline loop.
See if one of your magic words exists with a regular expression
...
profit?
(... meaning do your alert song and dance)
(profit being rejoice!)