{"id":10754,"date":"2011-11-24T21:03:21","date_gmt":"2011-11-24T13:03:21","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=10754"},"modified":"2025-04-04T00:44:24","modified_gmt":"2025-04-03T16:44:24","slug":"display-facebook-like-with-node-js","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/","title":{"rendered":"How to Display and Update &#8220;Facebook Likes&#8221; Using Node.js"},"content":{"rendered":"<p>By working through the sample codes from the <a href=\"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/\">previous post<\/a>, you might have understood the actual benefits of using Node.js. In today\u2019s post, we\u2019ll demonstrate a practical script that clearly shows the use of Node.js in event-based programming.<\/p>\n<p>We\u2019ll create a simple script that outputs the number of \u201cFacebook likes\u201d for a particular Facebook page. Additionally, we\u2019ll include a feature that updates the number of \u201cFacebook likes\u201d every 2 seconds.<\/p>\n<p>The output will be simple and plain, probably something like this: \u201cNumber of Likes: 2630405\u201d. You can style it using CSS. Let\u2019s get started!<\/p>\n<h2>To Give You an Idea<\/h2>\n<p>Before we dive into using Node.js, let\u2019s take a moment to consider what we\u2019d normally do with common server-side programming languages (like PHP). If you are thinking of making an AJAX call to find the number of <em>likes<\/em> every 2 seconds, you are correct. However, this may <strong>potentially increase the server overhead<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg\" alt=\"Example of multi-threaded execution\" width=\"500\" height=\"286\"><\/figure>\n<p>We can consider <strong>accessing <em>graph.facebook.com<\/em><\/strong>, which would be a <strong>time-consuming I\/O operation<\/strong>. Imagine 5 users accessing the same page that outputs the number of <em>likes<\/em>. The number of accesses to <em>graph.facebook.com<\/em> in 2 seconds will become 10 because everyone will update their number of <em>likes<\/em> once in 2 seconds, and it <strong>will be executed as a separate thread<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/event-based-execution.jpg\" alt=\"Example of event-based execution\" width=\"500\" height=\"289\"><\/figure>\n<p>That\u2019s not necessary with a Node.js server implementation. Only <strong>one access to the Facebook server is required<\/strong>, and the <strong>time to get and output the result (number of <em>likes<\/em>) can be greatly reduced<\/strong>.<\/p>\n<p>So, how are we going to implement this? That\u2019s what we are going to find out in the sections below.<\/p>\n<h2>Getting Started<\/h2>\n<p>Before we start, you should <strong>have Node.js installed and running on a v8 environment-supported web hosting account<\/strong>. Check out the topics, \u201cGetting started with Node.js\u201d and \u201cInstalling Node.js\u201d in our previous article, <a href=\"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/\">Beginner\u2019s Guide to Node.js<\/a> if you haven\u2019t.<\/p>\n<p>In the server, we <strong>access <code>graph.facebook.com<\/code> at an interval of 2 seconds<\/strong> and <strong>update the number of <em>likes<\/em><\/strong>. Let\u2019s call this \u201c<strong>ACTION1<\/strong>\u201c. We will prepare a page so that it will update itself via AJAX every 2 seconds.<\/p>\n<p>Consider many users accessing the same page. <strong>For every user\u2019s AJAX request, an event listener is attached in the server for the completion of \u201cACTION1\u201d<\/strong>. So whenever \u201cACTION1\u201d is completed, the event listeners will be triggered.<\/p>\n<p>Let\u2019s take a look at the server-side code.<\/p>\n<p><strong>The code:<\/strong><\/p>\n<pre>\r\nvar facebook_client = my_http.createClient(80, \"graph.facebook.com\");\r\nvar facebook_emitter = new events.EventEmitter(); \r\nfunction get_data() {\r\n    var request = facebook_client.request(\"GET\", \"\/19292868552\", {\"host\": \"graph.facebook.com\"});\r\n    request.addListener(\"response\", function(response) {\r\n        var body = \"\";\r\n        response.addListener(\"data\", function(data) {\r\n            body += data;\r\n        });\r\n        response.addListener(\"end\", function() {\r\n            var data = JSON.parse(body);\r\n            facebook_emitter.emit(\"data\", String(data.likes));\r\n        });\r\n    });\r\n    request.end();\r\n}\r\nmy_http.createServer(function(request, response) {\r\n    var my_path = url.parse(request.url).pathname;\r\n    if (my_path === \"\/getdata\") {\r\n        var listener = facebook_emitter.once(\"data\", function(data) {\r\n            response.writeHeader(200, { \"Content-Type\": \"text\/plain\" });\r\n            response.write(data);\r\n            response.end();\r\n        });\r\n    } else {\r\n        load_file(my_path, response);\r\n    }\r\n}).listen(8080);\r\nsetInterval(get_data, 1000);\r\nsys.puts(\"Server Running on 8080\");\r\n<\/pre>\n<p><strong>Code Explanation:<\/strong><\/p>\n<pre>\r\nvar facebook_client = my_http.createClient(80, \"graph.facebook.com\");\r\nvar facebook_emitter = new events.EventEmitter();\r\n<\/pre>\n<p>We create an <strong>HTTP client<\/strong> to access the Facebook Graph API using <code>facebook_client<\/code>. We also need the <code>EventEmitter()<\/code> function, which will trigger when \u201cACTION1\u201d is completed.<\/p>\n<p>This will become clear in the code described below.<\/p>\n<pre>\r\nfunction get_data() {\r\n    var request = facebook_client.request(\"GET\", \"\/19292868552\", {\"host\": \"graph.facebook.com\"});\r\n    request.addListener(\"response\", function(response) {\r\n        var body = \"\";\r\n        response.addListener(\"data\", function(data) {\r\n            body += data;\r\n        });\r\n        response.addListener(\"end\", function() {\r\n            var data = JSON.parse(body);\r\n            facebook_emitter.emit(\"data\", String(data.likes));\r\n        });\r\n    });\r\n    request.end();\r\n}\r\n<\/pre>\n<p>Function <code>get_data<\/code> <strong>fetches data from the Facebook API<\/strong>. We first <strong>create a GET request<\/strong> using the <code>request<\/code> method with the following syntax:<\/p>\n<pre>\r\nClient.request('GET', 'get_url', {\"host\": \"host_url\"});\r\n<\/pre>\n<p>The number \u201c<strong><em>19292868552<\/em><\/strong>\u201d is the Facebook ID of the page whose details we need to access. So the final page we are trying to access becomes: <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/developers.facebook.com\/docs\/graph-api\">http:\/\/graph.facebook.com\/19292868552<\/a>. After making the request, we need to <strong>add three listeners to it<\/strong>, as follows:<\/p>\n<ol>\n<li><strong>Response<\/strong> \u2013 This listener is triggered when the request starts receiving data. Here we set the body of the response to an empty string.<\/li>\n<li><strong>Data<\/strong> \u2013 As Node.js is asynchronous, the data is received in chunks. This data is added to the body variable to build up the complete response.<\/li>\n<li><strong>End<\/strong> \u2013 This listener is triggered when \u201cACTION1\u201d specified above is completed. The data returned by the Facebook Graph API call is in JSON format. We convert the string to a JSON object using the JavaScript function <code>JSON.parse<\/code>.<\/li>\n<\/ol>\n<p>You can see that a listener is attached for the <code>event_emitter<\/code> object. We <strong>need to trigger it at the end of \u201cACTION1\u201d<\/strong>. We trigger the listener explicitly with the method <code>facebook_emitter.emit<\/code>.<\/p>\n<pre>\r\n{\r\n    \"id\": \"19292868552\",\r\n    \"name\": \"Facebook Platform\",\r\n    \"picture\": \"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-ash2\/211033_19292868552_7506301_s.jpg\",\r\n    \"link\": \"https:\/\/www.facebook.com\/platform\",\r\n    \"likes\": 2738595,\r\n    \"category\": \"Product\/service\",\r\n    \"website\": \"http:\/\/developers.facebook.com\",\r\n    \"username\": \"platform\",\r\n    \"founded\": \"May 2007\",\r\n    \"company_overview\": \"Facebook Platform enables anyone to build social apps on Facebook and the web.\",\r\n    \"mission\": \"To make the web more open and social.\",\r\n    \"parking\": {\r\n        \"street\": 0,\r\n        \"lot\": 0,\r\n        \"valet\": 0\r\n    }\r\n}\r\n<\/pre>\n<p>The above represents the response of the Facebook Graph API call. To get the number of <em>likes<\/em>: <strong>take the likes object of the data object<\/strong>, <strong>convert it to a string<\/strong>, and <strong>pass it to the <code>emit<\/code> function<\/strong>.<\/p>\n<p>After this action, we <code>end<\/code> the request.<\/p>\n<pre>\r\nmy_http.createServer(function(request, response) {\r\n    var my_path = url.parse(request.url).pathname;\r\n    if (my_path === \"\/getdata\") {\r\n        var listener = facebook_emitter.once(\"data\", function(data) {\r\n            response.writeHeader(200, { \"Content-Type\": \"text\/plain\" });\r\n            response.write(data);\r\n            response.end();\r\n        });\r\n    } else {\r\n        load_file(my_path, response);\r\n    }\r\n}).listen(8080);\r\nsetInterval(get_data, 1000);\r\n<\/pre>\n<p>Creating the server is similar to the previous tutorial with a small change. For every URL (except <code>\/getdata<\/code>), we <strong>load the corresponding static file using the <code>load_file<\/code> function<\/strong> we defined earlier.<\/p>\n<p>The <code>http:\/\/localhost:8080\/getdata<\/code> is the URL for the AJAX request. In each AJAX request, we <strong>attach an event listener to <code>facebook_emitter<\/code><\/strong>. It is similar to <code>addListener<\/code> but the listener <strong>is removed after it is emitted to avoid a memory leak<\/strong>. If you need to check it out, just <strong>replace <code>once<\/code> with <code>addListener<\/code><\/strong>. We also call the <code>get_data<\/code> function once every second using <code>setInterval<\/code>.<\/p>\n<p>Next, we create the HTML page where the output displays.<\/p>\n<p><strong>The code:<\/strong><\/p>\n<pre>\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Facebook Likes&lt;\/title&gt;\r\n    &lt;link rel='stylesheet'&gt;\r\n    &lt;script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.4.2\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;p&gt;Number of Likes: &lt;b id=\"content_area\"&gt;Loading...&lt;\/b&gt;&lt;\/p&gt;\r\n    &lt;script type=\"text\/javascript\"&gt;\r\n    var content_area = $(\"#content_area\");\r\n    function load_content() {\r\n        $.get(\"\/getdata\", function(data) {\r\n            content_area.html(data);\r\n            load_content();\r\n        });\r\n    }\r\n    load_content();\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Code Explanation:<\/strong><\/p>\n<p>The jQuery AJAX part is pretty self-explanatory. Do check out the call of the <code>load_content<\/code> function. It looks like it <strong>runs in an infinite loop<\/strong>, and yes, it does. That\u2019s how the number of <em>likes<\/em> gets updated automatically.<\/p>\n<p>Each AJAX call <strong>will be delayed by the average time of 1 second<\/strong> because the delay in triggering each call is 1 second from the server. The AJAX request will remain incomplete for that 1 second.<\/p>\n<p>So there you go \u2013 a method of delaying an AJAX response from the server to get the number of Facebook <em>likes<\/em>. Drop questions in our comment section if you have any doubts or thoughts. Thanks!<\/p>","protected":false},"excerpt":{"rendered":"<p>By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today\u2019s post, we\u2019ll demonstrate a practical script that clearly shows the use of Node.js in event-based programming. We\u2019ll create a simple script that outputs the number of \u201cFacebook likes\u201d for a particular Facebook page.&hellip;<\/p>\n","protected":false},"author":216,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392,352],"tags":[4117,4616],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Display and Update &quot;Facebook Likes&quot; Using Node.js - Hongkiat<\/title>\n<meta name=\"description\" content=\"By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today&#039;s post, we&#039;ll\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Display and Update &quot;Facebook Likes&quot; Using Node.js\" \/>\n<meta property=\"og:description\" content=\"By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today&#039;s post, we&#039;ll\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2011-11-24T13:03:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-03T16:44:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg\" \/>\n<meta name=\"author\" content=\"Geo Paul\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Geo Paul\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/\"},\"author\":{\"name\":\"Geo Paul\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/96b9e48d0d487d6f8f43a8b73e8a2304\"},\"headline\":\"How to Display and Update &#8220;Facebook Likes&#8221; Using Node.js\",\"datePublished\":\"2011-11-24T13:03:21+00:00\",\"dateModified\":\"2025-04-03T16:44:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/\"},\"wordCount\":861,\"commentCount\":14,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/facebook-likes-with-node-js\\\/multi-threaded-execution.jpg\",\"keywords\":[\"Javascripts\",\"NodeJS\"],\"articleSection\":[\"Coding\",\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/\",\"name\":\"How to Display and Update \\\"Facebook Likes\\\" Using Node.js - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/facebook-likes-with-node-js\\\/multi-threaded-execution.jpg\",\"datePublished\":\"2011-11-24T13:03:21+00:00\",\"dateModified\":\"2025-04-03T16:44:24+00:00\",\"description\":\"By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today's post, we'll\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/facebook-likes-with-node-js\\\/multi-threaded-execution.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/facebook-likes-with-node-js\\\/multi-threaded-execution.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/display-facebook-like-with-node-js\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Display and Update &#8220;Facebook Likes&#8221; Using Node.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/96b9e48d0d487d6f8f43a8b73e8a2304\",\"name\":\"Geo Paul\",\"description\":\"Geo is an independent Web\\\/iPhone developer who enjoys working with PHP, Codeigniter, WordPress, jQuery, and Ajax. He has 4 years of experience in PHP and 2 years of experience in iOS application development.\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/geopaul\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Display and Update \"Facebook Likes\" Using Node.js - Hongkiat","description":"By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today's post, we'll","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/","og_locale":"en_US","og_type":"article","og_title":"How to Display and Update \"Facebook Likes\" Using Node.js","og_description":"By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today's post, we'll","og_url":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2011-11-24T13:03:21+00:00","article_modified_time":"2025-04-03T16:44:24+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg","type":"","width":"","height":""}],"author":"Geo Paul","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Geo Paul","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/"},"author":{"name":"Geo Paul","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/96b9e48d0d487d6f8f43a8b73e8a2304"},"headline":"How to Display and Update &#8220;Facebook Likes&#8221; Using Node.js","datePublished":"2011-11-24T13:03:21+00:00","dateModified":"2025-04-03T16:44:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/"},"wordCount":861,"commentCount":14,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg","keywords":["Javascripts","NodeJS"],"articleSection":["Coding","Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/","url":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/","name":"How to Display and Update \"Facebook Likes\" Using Node.js - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg","datePublished":"2011-11-24T13:03:21+00:00","dateModified":"2025-04-03T16:44:24+00:00","description":"By working through the sample codes from the previous post, you might have understood the actual benefits of using Node.js. In today's post, we'll","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/facebook-likes-with-node-js\/multi-threaded-execution.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/display-facebook-like-with-node-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Display and Update &#8220;Facebook Likes&#8221; Using Node.js"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/96b9e48d0d487d6f8f43a8b73e8a2304","name":"Geo Paul","description":"Geo is an independent Web\/iPhone developer who enjoys working with PHP, Codeigniter, WordPress, jQuery, and Ajax. He has 4 years of experience in PHP and 2 years of experience in iOS application development.","sameAs":["https:\/\/www.hongkiat.com\/blog\/"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/geopaul\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-2Ns","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/216"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=10754"}],"version-history":[{"count":4,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10754\/revisions"}],"predecessor-version":[{"id":73511,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10754\/revisions\/73511"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=10754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=10754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=10754"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=10754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}