{"id":111892,"date":"2021-03-08T12:53:09","date_gmt":"2021-03-08T07:23:09","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=111892"},"modified":"2024-04-12T14:31:39","modified_gmt":"2024-04-12T09:01:39","slug":"user-profile-access-by-the-graph-api-example","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/","title":{"rendered":"User Profile Access by the Graph API Example"},"content":{"rendered":"\n<p>This example covers getting profile information for the current user and printing their name, using the Graph API and the Facebook SDK for PHP.<\/p>\n\n\n\n<p>It assumes that you&#8217;ve already obtained an access token from one of the helpers found here.<\/p>\n\n\n\n<p>$fb = new Facebook\\Facebook([<\/p>\n\n\n\n<p>&#8216;app_id&#8217; =&gt; &#8216;{app-id}&#8217;,<\/p>\n\n\n\n<p>&#8216;app_secret&#8217; =&gt; &#8216;{app-secret}&#8217;,<\/p>\n\n\n\n<p>&#8216;default_graph_version&#8217; =&gt; &#8216;v2.10&#8217;,<\/p>\n\n\n\n<p>]);<\/p>\n\n\n\n<p>try {<\/p>\n\n\n\n<p>\/\/ Returns a `Facebook\\FacebookResponse` object<\/p>\n\n\n\n<p>$response = $fb-&gt;get(&#8216;\/me?fields=id,name&#8217;, &#8216;{access-token}&#8217;);<\/p>\n\n\n\n<p>} catch(Facebook\\Exceptions\\FacebookResponseException $e) {<\/p>\n\n\n\n<p>echo &#8216;Graph returned an error: &#8216; . $e-&gt;getMessage();<\/p>\n\n\n\n<p>exit;<\/p>\n\n\n\n<p>} catch(Facebook\\Exceptions\\FacebookSDKException $e) {<\/p>\n\n\n\n<p>echo &#8216;Facebook SDK returned an error: &#8216; . $e-&gt;getMessage();<\/p>\n\n\n\n<p>exit;<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>$user = $response-&gt;getGraphUser();<\/p>\n\n\n\n<p>echo &#8216;Name: &#8216; . $user[&#8216;name&#8217;];<\/p>\n\n\n\n<p>\/\/ OR<\/p>\n\n\n\n<p>\/\/ echo &#8216;Name: &#8216; . $user-&gt;getName();<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This example covers getting profile information for the current user and printing their name, using the Graph API and the Facebook SDK for PHP. It assumes that you&#8217;ve already obtained an access token from one of the helpers found here. $fb = new Facebook\\Facebook([ &#8216;app_id&#8217; =&gt; &#8216;{app-id}&#8217;, &#8216;app_secret&#8217; =&gt; &#8216;{app-secret}&#8217;, &#8216;default_graph_version&#8217; =&gt; &#8216;v2.10&#8217;, ]); try&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-111892","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>User Profile Access by the Graph API Example - Tutorial<\/title>\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.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"User Profile Access by the Graph API Example - Tutorial\" \/>\n<meta property=\"og:description\" content=\"This example covers getting profile information for the current user and printing their name, using the Graph API and the Facebook SDK for PHP. It assumes that you&#8217;ve already obtained an access token from one of the helpers found here. $fb = new FacebookFacebook([ &#8216;app_id&#8217; =&gt; &#8216;{app-id}&#8217;, &#8216;app_secret&#8217; =&gt; &#8216;{app-secret}&#8217;, &#8216;default_graph_version&#8217; =&gt; &#8216;v2.10&#8217;, ]); try...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T09:01:39+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/\",\"name\":\"User Profile Access by the Graph API Example - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2021-03-08T07:23:09+00:00\",\"dateModified\":\"2024-04-12T09:01:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"User Profile Access by the Graph API Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"User Profile Access by the Graph API Example - Tutorial","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.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/","og_locale":"en_US","og_type":"article","og_title":"User Profile Access by the Graph API Example - Tutorial","og_description":"This example covers getting profile information for the current user and printing their name, using the Graph API and the Facebook SDK for PHP. It assumes that you&#8217;ve already obtained an access token from one of the helpers found here. $fb = new FacebookFacebook([ &#8216;app_id&#8217; =&gt; &#8216;{app-id}&#8217;, &#8216;app_secret&#8217; =&gt; &#8216;{app-secret}&#8217;, &#8216;default_graph_version&#8217; =&gt; &#8216;v2.10&#8217;, ]); try...","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T09:01:39+00:00","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/","name":"User Profile Access by the Graph API Example - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2021-03-08T07:23:09+00:00","dateModified":"2024-04-12T09:01:39+00:00","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/user-profile-access-by-the-graph-api-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"User Profile Access by the Graph API Example"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/111892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=111892"}],"version-history":[{"count":1,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/111892\/revisions"}],"predecessor-version":[{"id":111893,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/111892\/revisions\/111893"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=111892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=111892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=111892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}