Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>the namespace and methods are inconsistent in the way that they are named and used. To access the apiClient, you must use FB.Facebook.apiClient.</p> <p>In short. Instead of calling:</p> <pre><code>FB.apiClient.get_apiKey(); </code></pre> <p>call:</p> <pre><code>FB.Facebook.apiClient.get_apiKey(); </code></pre> <p>Below, I have included a complete example, where I worked out several methods on the Connect and ApiClient APIs. This is working as of 1/22/09.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"&gt; &lt;body&gt; &lt;a target="_blank" href="http://developers.facebook.com/docs/?u=facebook.jslib"&gt;Facebook JavaScript API Documentation&lt;/a&gt; &lt;div id="comments_post"&gt; &lt;h3&gt;Post a comment to your Facebook Feed:&lt;/h3&gt; Demonstration to show what can be done with Facebook Connect, using the javascript API &lt;form name="comment_form" method="POST"&gt; &lt;div id="user"&gt; Name: &lt;input name="name" size="27"&gt;&lt;br /&gt; &lt;fb:login-button length='long' onlogin="update_user_box();"&gt;&lt;/fb:login-button&gt; &lt;/div&gt; &lt;br /&gt;&lt;textarea name="comment" rows="5" cols="30"&gt;&lt;/textarea&gt; &lt;br /&gt;&lt;input type="button" onclick="submit_comment();" value="Submit Comment"&gt; &lt;br /&gt;&lt;input type="button" onclick="updateStatus();" value="updateStatus"&gt; &lt;br /&gt;&lt;input type="button" onclick="updateStatusWithImage();" value="updateStatusWithImage"&gt; &lt;br /&gt;&lt;input type="button" onclick="postToFriendsWall();" value="postToFriendsWall"&gt; &lt;br /&gt;&lt;input type="button" onclick="postAnImage();" value="postAnImage"&gt; &lt;br /&gt;&lt;input type="button" onclick="alert(FB.Connect.get_loggedInUser());" value="get logged in user id"&gt; &lt;br /&gt;&lt;input type="button" onclick="getFriends()" value="get friends"&gt; &lt;br /&gt;&lt;input type="button" onclick="getEventMembers()" value="get event members"&gt; &lt;br /&gt;&lt;input type="button" onclick="getEventInfo()" value="get event info"&gt; &lt;div id="profile_pics"&gt;&lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; function update_user_box() { var user_box = document.getElementById("user"); user_box.innerHTML = "&lt;span&gt;" + "&lt;fb:profile-pic uid='loggedinuser' facebook-logo='true'&gt;&lt;/fb:profile-pic&gt;" + "Welcome, &lt;fb:name uid='loggedinuser' useyou='false'&gt;&lt;/fb:name&gt;" + "&lt;/span&gt;"; FB.XFBML.Host.parseDomTree(); } function update_user_not() { } function submit_comment() { comment_text = document.getElementsByName("comment")[0].value; var template_var = { "post-title": "pakt.com", "post-url": "http://www.pakt.com/pakt/?id=ce00f49ed79e17aa&amp;t=How_to_add_Facebook_Connect_to_your_website", "comment-text": comment_text, "images": [{ "src": "http://images.pakt.com/images/user/chris/thumb_chris_5df0eb914796c68.jpg", "href": "http://www.pakt.com/pakt/?id=ce00f49ed79e17aa&amp;t=How_to_add_Facebook_Connect_to_your_website"}] }; FB.Connect.streamPublish(comment_text); } function ClearComments() { document.getElementsByName("comment")[0].value = ""; } function updateStatus() { FB.Connect.streamPublish(); } var attachment = { 'media': [{ 'type': 'image', 'src': 'http://bit.ly/AJTnf', 'href': 'http://bit.ly/hifZk'}] }; function updateStatusWithImage() { FB.Connect.streamPublish('', attachment); } function postToFriendsWall() { FB.Connect.streamPublish('enjoying the Facebook javascript API much better than other versions', attachment, null, 1578234238); } function postAnImage() { function stream_callback(post_id, exception) { if (post_id) { post_to_my_server(post_id); } } FB.Connect.streamPublish('', attachment, null, null, 'What do you think?', stream_callback); } function getLoggedInUser() { var id = FB.Connect.get_loggedInUser(); alert(id); } function getFriends() { var widget_div = document.getElementById("profile_pics"); FB.ensureInit(function() { FB.Facebook.apiClient.friends_get(null, function(result) { var markup = ""; var num_friends = result ? Math.min(10, result.length) : 0; if (num_friends &gt; 0) { for (var i = 0; i &lt; num_friends; i++) { markup += '&lt;fb:profile-pic size="square" uid="' + result[i] + '" facebook-logo="true"&gt;' + ' &lt;/fb:profile-pic&gt;'; } } widget_div.innerHTML = markup; FB.XFBML.Host.parseDomElement(widget_div); }); //end of friends_get }); //end of ensureInit } function getEventMembers() { var widget_div = document.getElementById("profile_pics"); FB.ensureInit(function() { FB.Facebook.apiClient.events_getMembers(53288226963, function(result) { var markup = ""; var num_friends = result ? Math.min(10, result.attending.length) : 0; if (num_friends &gt; 0) { for (var i = 0; i &lt; num_friends; i++) { markup += '&lt;fb:profile-pic size="square" uid="' + result.attending[i] + '" facebook-logo="true"&gt;' + ' &lt;/fb:profile-pic&gt;'; } } widget_div.innerHTML = markup; FB.XFBML.Host.parseDomElement(widget_div); }); //end of friends_get }); //end of ensureInit } //this one doesn't work. don't know why yet. function getEventInfo() { var widget_div = document.getElementById("profile_pics"); var eids = new Array(); eids.push(53288226963); FB.Facebook.apiClient.events_get('', eids, 0, 0, 'attending', function(result) { var markup = ""; var num_friends = result ? Math.min(10, result.attending.length) : 0; if (num_friends &gt; 0) { for (var i = 0; i &lt; num_friends; i++) { markup += '&lt;fb:profile-pic size="square" uid="' + result.attending[i] + '" facebook-logo="true"&gt;' + ' &lt;/fb:profile-pic&gt;'; } } widget_div.innerHTML = markup; FB.XFBML.Host.parseDomElement(widget_div); }); //end of friends_get } &lt;/script&gt; &lt;script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" mce_src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; var api_key = "de57fdca3c665931e2a6b411f90a1cb4"; var channel_path = "xd_receiver.htm"; FB.init(api_key, channel_path, { "ifUserConnected": update_user_box }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload