{"id":946,"date":"2012-04-09T18:43:58","date_gmt":"2012-04-09T17:43:58","guid":{"rendered":"http:\/\/dpscomputing.com\/wordpress\/?p=946"},"modified":"2012-04-09T18:43:58","modified_gmt":"2012-04-09T17:43:58","slug":"facebook-development-for-websites-graph-api-introduction","status":"publish","type":"post","link":"https:\/\/www.dpscomputing.com\/blog\/2012\/04\/09\/facebook-development-for-websites-graph-api-introduction\/","title":{"rendered":"Facebook Development for Websites &#8211; Graph API Introduction"},"content":{"rendered":"<p><a href=\"http:\/\/dpscomputing.com\/wordpress\/wp-content\/uploads\/2009\/10\/facebook.jpg\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"169\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2009\/10\/14\/facebook\/facebook\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2009\/10\/facebook-e1343000923652.jpg\" data-orig-size=\"400,150\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Facebook\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2009\/10\/facebook-e1343000923652.jpg\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2009\/10\/facebook-e1343000923652.jpg\" tabindex=\"0\" role=\"button\" class=\"alignright  wp-image-169\" title=\"Facebook\" src=\"http:\/\/dpscomputing.com\/wordpress\/wp-content\/uploads\/2009\/10\/facebook.jpg\" alt=\"\" width=\"288\" height=\"109\" \/><\/a>The graph API is one of the new application programming interfaces launched by Facebook to replace the old RESTful API.<\/p>\n<p>The graph API allows developers to tap into the &#8216;social graph&#8217; and retrieve information from Facebook. \u00a0It can be used to retrieve public information and also, with the appropriate permissions, more personal information, information about your friends, employment &#8211; basically anything that you share to the public or explicitly authorise the app or website to access.<\/p>\n<p>The graph API is not just limited to people and their profiles on Facebook. \u00a0It can also be used to access things such as events, pages and groups. \u00a0If it is on Facebook, then chances are you can access and retrieve the information using the graph API.<\/p>\n<p>The &#8216;social graph&#8217; on Facebook contains everything within the &#8216;Facebook world&#8217; and how it connects and relates to each other. \u00a0You can get information on who is friends with who, who is attending which events, and who likes a particular celebrity.<\/p>\n<p>Facebook treats all these different types of information as &#8216;objects&#8217;. \u00a0There are different types of objects but essentially, everything within the world of Facebook is an object and it is assigned its own unique ID which, as the name suggest, uniquely identifies an individual object.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"947\" data-permalink=\"https:\/\/www.dpscomputing.com\/blog\/2012\/04\/09\/facebook-development-for-websites-graph-api-introduction\/fbgraphapi\/\" data-orig-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2012\/04\/fbgraphapi.gif\" data-orig-size=\"300,271\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Facebook &amp;#8211; Graph API\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2012\/04\/fbgraphapi.gif\" data-large-file=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2012\/04\/fbgraphapi.gif\" tabindex=\"0\" role=\"button\" class=\"alignleft  wp-image-947\" title=\"Facebook - Graph API\" src=\"http:\/\/dpscomputing.com\/wordpress\/wp-content\/uploads\/2012\/04\/fbgraphapi.gif\" alt=\"Facebook - Graph API\" width=\"180\" height=\"163\" srcset=\"https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2012\/04\/fbgraphapi.gif 300w, https:\/\/www.dpscomputing.com\/blog\/wp-content\/uploads\/2012\/04\/fbgraphapi-150x135.gif 150w\" sizes=\"auto, (max-width: 180px) 100vw, 180px\" \/><\/p>\n<p>Data that is retrieved from Facebook is in a JSON (JavaScript Object Notation) format. \u00a0This is a widely used and standardised format which has become commonplace for applications and websites sharing information over the Internet. \u00a0Many programming languages will have support for JSON data types and will contain functions which can change the data into a standard format for that programming language.<\/p>\n<p>For example, if you are using ColdFusion, then the JSON data returned by Facebook to your website is essentially, to all intents and purposes, as far as ColdFusion is concerned, a long string with delimiters. \u00a0In ColdFusion, this makes the data hard to work with. \u00a0It would be easier if it was a structure, with appropriately named attributes. \u00a0That&#8217;s no problem, ColdFusion includes a very handy function called &#8216;DeserializeJSON&#8217;. \u00a0This function can convert the returned data into an array (structure) of appropriately named attributes ready for you to use and manipulate within your application or website.<\/p>\n<p>An example of the data returned by Facebook from a request to the Graph API is shown below:<\/p>\n<p><span style=\"font-family: 'courier new', courier;\"><code>{\u00a0<\/code><\/span><br \/>\n<span style=\"font-family: 'courier new', courier;\">\u00a0 \u00a0 &#8220;name&#8221;: &#8220;Facebook Platform&#8221;,\u00a0<\/span><br \/>\n<span style=\"font-family: 'courier new', courier;\">\u00a0 \u00a0 &#8220;website&#8221;: &#8220;http:\/\/developers.facebook.com&#8221;,<br \/>\n&#8220;username&#8221;: &#8220;platform&#8221;,<br \/>\n&#8220;founded&#8221;: &#8220;May 2007&#8221;,<br \/>\n&#8220;company_overview&#8221;: &#8220;Facebook Platform enables anyone to build&#8230;&#8221;,<br \/>\n&#8220;mission&#8221;: &#8220;To make the web more open and social.&#8221;,<br \/>\n&#8220;products&#8221;: &#8220;Facebook Application Programming Interface (API)&#8230;&#8221;,<br \/>\n&#8220;likes&#8221;: 449921,<br \/>\n&#8220;id&#8221;: 19292868552,<br \/>\n&#8220;category&#8221;: &#8220;Technology&#8221;<br \/>\n}<\/span><\/p>\n<p>(Facebook, no date).<\/p>\n<p>The example above shows the returned public data about the Facebook Platform page. \u00a0It describes the general attributes and information of the page. \u00a0This can be used in data on your own website or it can be used in part or whole in your own functions and calculations.<\/p>\n<p>The graph API can be used to access many items including:<\/p>\n<ul>\n<li>Users<\/li>\n<li>Pages<\/li>\n<li>Events<\/li>\n<li>Groups<\/li>\n<li>Applications<\/li>\n<li>Status Messages<\/li>\n<li>Photos<\/li>\n<li>Photo Albums<\/li>\n<li>Profile Pictures<\/li>\n<li>Videos<\/li>\n<li>Notes<\/li>\n<li>Checkins<\/li>\n<\/ul>\n<p>The power of the Graph API cannot be overstated &#8211; when integrated correctly into a quality third party application, its full power can be realised and your application or website can be instantly taken from being standalone, to fully integrated with the Facebook website (and its many millions of users).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The graph API is one of the new application programming interfaces launched by Facebook to replace the old RESTful API. The graph API allows developers to tap into the &#8216;social graph&#8217; and retrieve information&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[231],"tags":[72,209,219,230,228,310,313,223,311,312,226,315,225,314],"class_list":["post-946","post","type-post","status-publish","format-standard","hentry","category-facebook-developer-series-articles","tag-facebook","tag-facebook-developer","tag-facebook-developer-article","tag-facebook-developer-article-series","tag-facebook-developer-series","tag-facebook-development-for-websites","tag-fb-developers","tag-fb-development","tag-graph-api","tag-open-graph-api","tag-social-media","tag-social-media-integration","tag-social-networks","tag-third-party-applications"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3nsfA-fg","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/comments?post=946"}],"version-history":[{"count":2,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/946\/revisions"}],"predecessor-version":[{"id":949,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/posts\/946\/revisions\/949"}],"wp:attachment":[{"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/media?parent=946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/categories?post=946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dpscomputing.com\/blog\/wp-json\/wp\/v2\/tags?post=946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}