Log In
Status:
waiting
|
Disconnect
|
Logout
<h1>Reading from the Graph API</h1> <p>Here we'll show you how to make a simple request from the Graph API <code>/me</code> endpoint using the FB.api() SDK function. It'll retrieve your name and profile photo. Make sure you've logged in by clicking the Login button in the top left.</p> <h2>Using FB.api()</h2> <div id="accountInfo" style="padding-top: 20px">You haven't logged in yet.</div> <script> function basicAPIRequest() { FB.api('/me?fields=name,picture', function(response) { Log.info('API response', response); document.getElementById('accountInfo').innerHTML = ('<img src="' + response.picture.data.url + '"> ' + response.name); }); } FB.getLoginStatus(function(response) { Log.info('Login Status', response); if (response.status === 'connected') { basicAPIRequest(); } }); </script> <h3>Related Guides</h3> <p>Read <a href="https://developers.facebook.com/docs/javascript/quickstart/#graphapi">our quickstart to using the JavaScript SDK for Graph API calls</a> for more info.</p>
Examples
Website
Website
Canvas
Page Tab
Run Code
Clear